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

Update Apache HttpClient 4.0 to Instrumenter API #3042

Merged
merged 13 commits into from
May 20, 2021
Merged

Update Apache HttpClient 4.0 to Instrumenter API #3042

merged 13 commits into from
May 20, 2021

Conversation

trask
Copy link
Member

@trask trask commented May 19, 2021

Another small part of #2713

Comment on lines 30 to 41
URI uri = request.getURI();
int port = uri.getPort();
if (port != -1) {
return (long) port;
}
switch (uri.getScheme()) {
case "http":
return 80L;
case "https":
return 443L;
}
return 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.

do you think I should extract UriNetAttributesExtractor similar to InetSocketAddressNetAttributesExtractor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it correct to say URI will be more common in automatic instrumentation vs library instrumentation since it's a result of not having access to the internals? If so, possibly not, to encourage library authors adding OTel support to expose the more useful type.

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'm not sure how common yet, will know soon 😁 (won't extract anything common for now and we can revisit later)

Copy link
Member

Choose a reason for hiding this comment

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

There's one advantage to using URI in the instrumenter API: if we used it everywhere then we could have encapsulate the userInfo sanitization logic in the attribute extractor (well, we still can do it right now, but with a String url() method we'd have to have one more type conversion)

Comment on lines +11 to +12
enum HttpHeaderSetter implements TextMapSetter<HttpUriRequest> {
INSTANCE;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we don't really need to have setters/getters be enums, we can just create a new instance and pass to the instrumenter.

Copy link
Member Author

Choose a reason for hiding this comment

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

will send a follow-up PR to change in all (few) existing places so @anuraaga can weigh in

Copy link
Member Author

Choose a reason for hiding this comment

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

trask and others added 10 commits May 20, 2021 14:39
…ent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientHttpAttributesExtractor.java

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
* Fix flaky spring batch test

* Update instrumentation/spring/spring-batch-3.0/javaagent/src/test/groovy/ItemLevelSpanTest.groovy

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
* split out inner classes into separate files
* and since they're public API I made them a little bit better: added javadocs, renamed classes/methods

Getting the `...extension.muzzle` package stable is the first step to extracting the muzzle compile time plugin - the plugin may have a bit different release lifecycle than the main project and getting those classes stable will help a lot with eliminating breaking changes.
@trask trask merged commit bdfd22f into open-telemetry:main May 20, 2021
@trask trask deleted the apache-httpclient-4.0-to-instrumenter-api branch May 20, 2021 22:54
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.

5 participants