Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ResponseMetered annotation for Jersey Resources #1185

Closed

Conversation

dennyac
Copy link
Contributor

@dennyac dennyac commented Sep 7, 2017

For Dropwizard services, we currently have metrics for response rates by HTTP status code (1xx, 2xx, 3xx, 4xx, 5xx) captured at Jetty . There have been use cases where it would be helpful to have it on a Jersey Resource method/class level. To achieve that, I've added @ResponseMetered annotation which will add meters for 1xx/2xx/3xx/4xx/5xx responses. I've reused the logic from com.codahale.metrics.jetty9.InstrumentedHandler to capture the metrics.

I hope you find this helpful and I'm open to suggestions/feedback. Thanks!

@Path("/")
@Produces(MediaType.TEXT_PLAIN)
public class InstrumentedResource {
    @GET
    @ResponseMetered
    @Path("/responseMeteredEndpoint")
    public Response responseMeteredEndpoint() {
        return Response.ok().build();
    }
}

@dennyac
Copy link
Contributor Author

dennyac commented Sep 7, 2017

Hi @arteam, my PR is based on the master branch. I noticed that most of the PRs are based on 3.2-development and 4.0-development branch. If required, I can create PRs for those branches as well.

I hope others have come across this use case and find this helpful.

@jplock
Copy link
Member

jplock commented Sep 7, 2017

@dennyac 4.0-development is the branch for the next major release.

@dennyac
Copy link
Contributor Author

dennyac commented Sep 7, 2017

Thanks @jplock . I'll create another PR based on the 4.0-development branch then.

@arteam
Copy link
Member

arteam commented Sep 8, 2017

It seems that you could even create against the 3.2-development branch, because the feature doesn't require Java 8.

@arteam
Copy link
Member

arteam commented Sep 8, 2017

Having said that, in any case PR will be gladly accepted. Thank you for working on this!

@dennyac
Copy link
Contributor Author

dennyac commented Sep 8, 2017

Thanks @arteam , I'll work on PRs for both 3.2-development and 4.0-development

@arteam
Copy link
Member

arteam commented Sep 15, 2017

I've decided against adding new features to 3.2 branch. I would to keep only for bugfixes and continue new development in the 4.0 branch.

@arteam arteam closed this Sep 15, 2017
@arteam
Copy link
Member

arteam commented Sep 15, 2017

Thank you for the contribution!

@dennyac
Copy link
Contributor Author

dennyac commented Oct 5, 2017

Hi @arteam , are there any timelines on when metrics 4.0 will be included in dropwizard?

I totally understand the reasoning behind only having bug fixes for 3.2 and new features in 4.0. But it would be really helpful to have this feature included in the metrics-jersey2 module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants