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

Apache HTTP client instrumentation with Observation #3312

Merged

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented Jul 25, 2022

Adds Observation-based instrumentation for the Apache HTTP client while being backwards compatible. Configuring an ObservationRegistry (that is not a no-op) causes the Observation instrumentation to be used instead of instrumentation directly with Timer.

@shakuzen shakuzen added enhancement A general enhancement module: micrometer-core An issue that is related to our core module labels Jul 25, 2022
@shakuzen shakuzen added this to the 1.10.0-M4 milestone Jul 25, 2022
@shakuzen shakuzen force-pushed the apache-http-client-to-obs-api branch 2 times, most recently from b8fa4ca to de6229f Compare August 1, 2022 09:32
@shakuzen shakuzen modified the milestones: 1.10.0-M4, 1.10 backlog Aug 8, 2022
@shakuzen shakuzen force-pushed the apache-http-client-to-obs-api branch from 6b068fd to c6011b5 Compare August 17, 2022 09:19
Work-in-progress on adding Observation-based instrumentation to Apache HTTP client while being backwards compatible.
Adapts to breaking changes made in main, and updates the code to work with global conventions and allows custom conventions to be configured locally. Previously the default convention relied on accepting config that would not be available to third-part implementations. This has been moved to the context instead.
@shakuzen shakuzen force-pushed the apache-http-client-to-obs-api branch from c6011b5 to 93166ee Compare August 22, 2022 02:20
@shakuzen shakuzen force-pushed the apache-http-client-to-obs-api branch from 4fcade7 to 3bf0bff Compare August 22, 2022 07:58
@shakuzen shakuzen changed the title WIP Apache HTTP client instrumentation with Observation Apache HTTP client instrumentation with Observation Aug 22, 2022
@shakuzen shakuzen marked this pull request as ready for review August 22, 2022 11:38

@Override
public String getContextualName(ApacheHttpClientContext context) {
return "HTTP " + getMethodString(context.getCarrier());
Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen this hard coded quite a few times - I wonder if we can extract this somehow, somewhere? 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

Since how to get the method will be different for each implementation I'm not sure we really can. This is exactly what we were trying to do with the HTTP abstractions for request/response, but we ended up going a different direction.


}

// TODO add test for status = IO_ERROR case.
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 wanted to add a test for this, but I wasn't sure how. If someone knows how to test this scenario with the Apache HTTP client, let me know. The scenarios are when the response returned from execute is null and when calling execute results in an IOException

@shakuzen shakuzen merged commit 4f4f776 into micrometer-metrics:main Aug 25, 2022
@shakuzen shakuzen modified the milestones: 1.10 backlog, 1.10.0-M5 Aug 25, 2022
@shakuzen shakuzen deleted the apache-http-client-to-obs-api branch August 25, 2022 07:57
izeye added a commit to izeye/micrometer that referenced this pull request Sep 18, 2022
izeye added a commit to izeye/micrometer that referenced this pull request Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement module: micrometer-core An issue that is related to our core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants