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

Added Jetty reference doc #4584

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ asciidoc:
include-java: 'example$docs-src/test/java/io/micrometer/docs'
include-resources: 'example$docs-src/test/resources'
include-core-test-java: 'example$core-test'
include-micrometer-test-java: 'example$micrometer-test'
1 change: 1 addition & 0 deletions docs/modules/ROOT/examples/micrometer-test
17 changes: 16 additions & 1 deletion docs/modules/ROOT/pages/reference/jetty.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[[overview]]
= 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:
Expand All @@ -23,4 +26,16 @@ resourceConfig.register(new MetricsApplicationEventListener(
"http.server.requests",
true));
ServletContainer servletContainer = new ServletContainer(resourceConfig);
----
----

[[overview-observation]]
== Eclipse Observation Jersey Instrumentation

Below you can find an example of how to instrument Jersey with https://docs.micrometer.io/micrometer/reference/observation.html[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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not use relative links to the Observation docs rather than the absolute link?


[source,java,subs=+attributes]
-----
// Setting up instrumentation
include::{include-micrometer-test-java}/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java[tags=setup, indent=0]
include::{include-micrometer-test-java}/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java[tags=setup_2, indent=0]
-----
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ protected URI startInstrumentedWithMetricsServer() throws Exception {
@Nullable
@Override
protected URI startInstrumentedWithObservationsServer() throws Exception {
jerseyTest = jerseyWithListener(new ObservationApplicationEventListener(getObservationRegistry(), timerName()));
jerseyTest = jerseyWithListener(
// tag::setup[]
new ObservationApplicationEventListener(getObservationRegistry(), timerName())
// end::setup[]
);
return setupUri(jerseyTest);
}

Expand All @@ -57,8 +61,10 @@ private JerseyTest jerseyWithListener(Object listener) {
return new JerseyTest() {
@Override
protected Application configure() {
// tag::setup_2[]
ResourceConfig config = new ResourceConfig();
config.register(listener);
// end::setup_2[]
config.register(TestResource.class);
return config;
}
Expand Down