Skip to content

Commit a5c1b72

Browse files
committed
Update documentation for Jetty connection metrics
The configuration necessary for getting all the Jetty connection metrics changed with gh-4514. This updates the corresponding documentation to include this. Closes gh-4981
1 parent 4cd3490 commit a5c1b72

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

docs/modules/ROOT/pages/reference/jetty.adoc

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
[[overview]]
22
= Eclipse Jetty and Jersey Instrumentation
33

4+
== Jetty
5+
46
Micrometer supports binding metrics to Jetty through `Connection.Listener`.
57

6-
You can collect metrics from Jetty by adding `JettyConnectionMetrics`, as follows:
8+
You can collect metrics from a Jetty `Connector` by configuring it with `JettyConnectionMetrics`, as follows:
79

810
[source,java]
911
----
1012
Server server = new Server(0);
11-
Connector connector = new ServerConnector(server);
12-
connector.addBean(new JettyConnectionMetrics(registry, connector, Tags.of("foo", "bar"));
13+
NetworkTrafficServerConnector connector = new NetworkTrafficServerConnector(server);
14+
JettyConnectionMetrics metrics = new JettyConnectionMetrics(registry, connector);
15+
connector.addBean(metrics); //<1>
16+
connector.setNetworkTrafficListener(metrics); //<2>
1317
server.setConnectors(new Connector[] { connector });
1418
----
19+
<1> Register general connection metrics
20+
<2> Registers metrics for bytes in/out on this connector
21+
22+
Alternatively, you can apply the metrics instrumentation to all connectors on a `Server` as follows:
23+
24+
[source,java]
25+
----
26+
JettyConnectionMetrics.addToAllConnectors(server, registry);
27+
----
28+
29+
Connection metrics can be configured on a client as well, but bytes in/out will not be available when instrumenting a client.
30+
31+
.Configure instrumentation for a Jetty client
32+
[source,java]
33+
----
34+
HttpClient httpClient = new HttpClient();
35+
httpClient.addBean(new JettyConnectionMetrics(registry));
36+
----
37+
38+
== Jersey
1539

1640
Micrometer also supports binding metrics to Jersey through `ApplicationEventListener`.
1741

0 commit comments

Comments
 (0)