2

I have a Dropwizard project which has resources based on generated Java interfaces, Resource looks like:

@Path("/foo")
public class FooResource implements FooApi {

    @Override  // This method overrides the one from FooApi interface
    public Response fooGet() {
      ...
    }
}

FooApi is the interface which was generated from OpenAPI contract:

@Path("/foo")
@Api(description = "Will list foos.")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2077-10-23T19:04:20.922+03:00[Europe/Kiev]")
public interface FooApi {

    @GET
    @Produces({ "application/json" })
    @ApiOperation(value = "Will list foos.", notes = "Will list foos.", tags={ "Foo" })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "OK", response = Foo.class, responseContainer = "List") })
    Response fooGet();
}

So now I'm trying to integrate this resource with jersey metrics by annotate methods with @Timed or @Metered, like

@Timed
@Override  // This method overrides the one from FooApi interface
public Response fooGet() {
  ...
}

But in this case NO metrics will be produced.

I've also tried to annotate class instead:

@Timed
@Path("/foo")
public class FooResource implements FooApi {

And this time I see that metrics were produced but those are too generic for me.

I suspect that problem is related to InstrumentedResourceMethodApplicationListener and the way it extracts annotated methods, but maybe there is more easy solution rather then override this listener?

Vladimir
  • 281
  • 3
  • 6

0 Answers0