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

Consistent tagging and propagate sendAsync throwable #5553

Merged

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented Oct 8, 2024

When handling the sendAsync call in our instrumentation, we were not propagating the throwable observed to the CompletionFuture returned. This fixes that and adds a test. To keep tagging consistent in the case where response is null or not, this also updates tagging to always include status and outcome. In case the response is null, they will have value UNKNOWN for now. This is a change from before for this case, but the behavior before is problematic for the Prometheus registry that expects a consistent set of tags. The change is adding tags that weren't there before in the case response is null, so it should generally not break users.

Resolves gh-5136

When handling the sendAsync call in our instrumentation, we were not propagating the throwable observed to the CompletionFuture returned. This fixes that and adds a test. To keep tagging consistent in the case where response is null or not, this also updates tagging to always include `status` and `outcome`. In case the response is null, they will have value `UNKNOWN` for now. This is a change from before for this case, but the behavior before is problematic for the Prometheus registry that expects a consistent set of tags. The change is adding tags that weren't there before in the case response is null, so it should generally not break users.
assertThatThrownBy(response::join).isInstanceOf(CompletionException.class);
assertThatNoException().isThrownBy(() -> meterRegistry.get("http.client.requests")
.tag("method", "GET")
// TODO fix status/uri in exceptional cases where response may be null
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not a TODO we should tackle in this PR. This should probably be fixed on main instead since it results in a change in behavior. Ideally, we should add more to our HttpClientTimingInstrumentationVerificationTests to ensure consistent behavior across instrumentations. The issue, if I remember correctly, is that some HTTP clients cannot instrument the case where the response is null.

@shakuzen shakuzen merged commit 81b53d3 into micrometer-metrics:1.13.x Oct 10, 2024
7 checks passed
@shakuzen shakuzen deleted the jdk11-httpclient-throws branch October 10, 2024 02:39
izeye added a commit to izeye/micrometer that referenced this pull request Nov 23, 2024
izeye added a commit to izeye/micrometer that referenced this pull request Nov 23, 2024
jonatan-ivanov pushed a commit that referenced this pull request Dec 4, 2024
* Apply gh-5553 to io.micrometer.core.instrument.binder.jdk

* Fix missing error on context in MicrometerHttpClient.sendAsync()

This commit also applies gh-5705.
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.

2 participants