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

JettyClientMetrics compatibility with Jetty 12 #4756

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented Feb 19, 2024

Copy JettyClientMetrics and related classes to a micrometer-jetty12 module from micrometer-core (based on Jetty 9) and migrate the Jetty API accordingly.

https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-migration-11-to-12

Resolves #4609

@shakuzen shakuzen linked an issue Feb 19, 2024 that may be closed by this pull request
@shakuzen
Copy link
Member Author

The micrometer-samples-jetty12 module can be removed after this and #4753 are merged and the test there is added to the micrometer-jetty12 module. A question that's tangential to this pull request is whether we copy JettyConnectionMetrics from micrometer-core to micrometer-jetty12 or keep it there undeprecated since it works with Jetty 9 through 12.

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

@WireMockTest
Copy link
Member Author

Choose a reason for hiding this comment

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

I reworked the tests to use WireMock since that seems easier and more similar to other tests we have.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shame it doesn't support HTTP/2 or HTTP/3 (or TLS properly)

@shakuzen shakuzen force-pushed the jetty12-client branch 3 times, most recently from 57edf33 to ff96e60 Compare February 19, 2024 13:52
@shakuzen shakuzen marked this pull request as ready for review February 19, 2024 13:56
@shakuzen
Copy link
Member Author

@joakime if you have some time to take a look at this, it's the client-side instrumentation updated for Jetty 12. It's mostly a copy of the existing Jetty client instrumentation for Jetty 9, but if you spot anything that looks unusual or could be improved, please let us know.

Comment on lines +156 to +161
public static KeyValue outcome(@Nullable Result result) {
if (result == null) {
return OUTCOME_UNKNOWN;
}
return Outcome.forStatus(result.getResponse().getStatus()).asKeyValue();
}
Copy link
Contributor

@joakime joakime Feb 19, 2024

Choose a reason for hiding this comment

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

With HTTP/1 the existence of the status code is just what the response commit buffer had, not that the request/response is complete or successful (depending on the mode used in HTTP/1 there could be a socket exception, or even just a normal socket closure with incomplete data see "close-delimited message" on the HTTP/1 specs).

With HTTP/2 and HTTP/3 the status code is just what was seen on the first buffer.
Those responses can also be canceled via the HTTP/2 and HTTP/3 protocols (eg: GOAWAY) and be incomplete, these would be seen as protocol specific exceptions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Those are interesting scenarios and I don't think we're properly handling them right now. It sounds like something we could write a test for and then figure out how to (or if we can) improve all the different HTTP instrumentations (/cc @bclozel). For HTTP client instrumentation we have a small suite of tests that we run all of them against; see HttpClientTimingInstrumentationVerificationTests which is extended in this pull request to run the instrumentation against it in Jetty12ClientTimingInstrumentationVerificationTests.

Are there existing tests in Jetty for this scenario that we could get inspiration from to add to our test suite?

We haven't done a good job of testing with HTTP/2 or HTTP/3 so far, so that's another point of improvement.

@joakime
Copy link
Contributor

joakime commented Feb 19, 2024

I don't see protocol/version specific details in these metrics.

I'm especially concerned about that kind of metric in light of PR jetty/jetty.project#11368

@shakuzen
Copy link
Member Author

I don't see protocol/version specific details in these metrics.

Thanks for pointing that out and sharing the Jetty PR. Right now it may be more straightforward to tag the protocol, but it sounds like after that PR, there may be layering of protocols and that makes it complicated to map that to tags. It's certainly something to explore, though. Maybe it'd be best to open an issue for it and track it separately so we don't block merging this on that. What do you think?

Add JettyClientMetrics and related classes to a micrometer-jetty12 module and migrate Jetty API accordingly.
@shakuzen shakuzen merged commit 1eabb04 into micrometer-metrics:main Feb 28, 2024
6 checks passed
@shakuzen shakuzen deleted the jetty12-client branch February 28, 2024 04:09
izeye added a commit to izeye/micrometer that referenced this pull request May 11, 2024
@izeye izeye mentioned this pull request May 11, 2024
shakuzen pushed a commit that referenced this pull request May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make JettyClientMetrics compatible with Jetty12
3 participants