Guest User

Untitled

a guest
Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. @Path("/prometheus")
  2. public class SimplePrometheusEndpoint {
  3.  
  4. {
  5. // Initialize the default metrics for the hotspot VM
  6. DefaultExports.initialize();
  7. }
  8.  
  9.  
  10. @GET
  11. @Path("/metrics")
  12. @Produces(MediaType.TEXT_PLAIN)
  13. public StreamingOutput metrics() {
  14.  
  15. return output -> {
  16. try (final Writer writer = new OutputStreamWriter(output)) {
  17. TextFormat.write004(writer, CollectorRegistry.defaultRegistry.metricFamilySamples());
  18. }
  19. };
  20. }
  21.  
  22. }
Add Comment
Please, Sign In to add comment