For the latest stable version, please use Micrometer 1.14.1! |
Eclipse Jetty and Jersey Instrumentation
Micrometer supports binding metrics to Jetty through Connection.Listener
.
You can collect metrics from Jetty by adding JettyConnectionMetrics
, as follows:
Server server = new Server(0);
Connector connector = new ServerConnector(server);
connector.addBean(new JettyConnectionMetrics(registry, connector, Tags.of("foo", "bar"));
server.setConnectors(new Connector[] { connector });
Micrometer also supports binding metrics to Jersey through ApplicationEventListener
.
You can collect metrics from Jersey by adding MetricsApplicationEventListener
, as follows:
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(new MetricsApplicationEventListener(
registry,
new DefaultJerseyTagsProvider(),
"http.server.requests",
true));
ServletContainer servletContainer = new ServletContainer(resourceConfig);
Eclipse Observation Jersey Instrumentation
Below you can find an example of how to instrument Jersey with Micrometer Observation. That means that depending on your Observation Handler configuration you instrument once, and can have multiple benefits out of it (e.g. metrics, distributed tracing).
// Setting up instrumentation
new ObservationApplicationEventListener(getObservationRegistry(), timerName())
ResourceConfig config = new ResourceConfig();
config.register(listener);