Created
February 7, 2018 10:33
-
-
Save matzew/4eddb4997de2f0ed0902d29b6608ddb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/prometheus") | |
public class SimplePrometheusEndpoint { | |
{ | |
// Initialize the default metrics for the hotspot VM | |
DefaultExports.initialize(); | |
} | |
@GET | |
@Path("/metrics") | |
@Produces(MediaType.TEXT_PLAIN) | |
public StreamingOutput metrics() { | |
return output -> { | |
try (final Writer writer = new OutputStreamWriter(output)) { | |
TextFormat.write004(writer, CollectorRegistry.defaultRegistry.metricFamilySamples()); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment