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

Separate HTTP client/server AttributesExtractors #4195

Conversation

mateuszrzeszutek
Copy link
Member

@mateuszrzeszutek mateuszrzeszutek commented Sep 23, 2021

This PR splits HttpAttributesExtractor into HttpClientAttributesExtractor and HttpServerAttributesExtractor - I need to do that before I implement the http headers semantic attributes that were recently added to the spec (because we'll want separate configurations for clients/servers).

And maybe, if we decide on a solution here we'll be able to get #3700 done

@@ -21,7 +21,7 @@
* #onStart(AttributesBuilder, Object)} to have it available during sampling.
*
* @see DbAttributesExtractor
* @see HttpAttributesExtractor
* @see HttpClientAttributesExtractor
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @see HttpClientAttributesExtractor
* @see HttpClientAttributesExtractor
* @see HttpServerAttributesExtractor

Comment on lines +28 to +32

// TODO: these are specific to servers, should we remove those?
set(attributes, SemanticAttributes.HTTP_TARGET, target(request));
set(attributes, SemanticAttributes.HTTP_HOST, host(request));
set(attributes, SemanticAttributes.HTTP_SCHEME, scheme(request));
Copy link
Member

Choose a reason for hiding this comment

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

+1 for removing these. We can always add them later if there's really a compelling reason.

cc: @lmolkova

Comment on lines +34 to +36

// TODO: this is specific to clients, should we remove this?
set(attributes, SemanticAttributes.HTTP_URL, url(request));
Copy link
Member

Choose a reason for hiding this comment

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

same, +1 for removing this and we can always add it later if there's really a compelling reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that we can remove this. I arbitrary took a couple of server instrumentation's extractor, and they all returned null for attributes above

Comment on lines +48 to +53
private String extractRoute(REQUEST request) {
if (attributesExtractor instanceof HttpServerAttributesExtractor) {
return ((HttpServerAttributesExtractor<REQUEST, ?>) attributesExtractor).route(request);
}
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

is it worth HttpClientSpanNameExtractor and HttpServerSpanNameExtractor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, maybe we could have different factory methods in HttpSpanNameExtractor? One accepting the client extractor, the other the server one

Copy link
Contributor

Choose a reason for hiding this comment

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

instanceof seems OK too from what I can tell

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

Comment on lines +48 to +53
private String extractRoute(REQUEST request) {
if (attributesExtractor instanceof HttpServerAttributesExtractor) {
return ((HttpServerAttributesExtractor<REQUEST, ?>) attributesExtractor).route(request);
}
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

instanceof seems OK too from what I can tell

@trask
Copy link
Member

trask commented Sep 24, 2021

👍 this is great, going to merge, TODOs make sense (to try) as follow-up(s)

@trask trask merged commit a277a8b into open-telemetry:main Sep 24, 2021
@mateuszrzeszutek mateuszrzeszutek deleted the separate-http-client-server-attributes-extractors branch September 28, 2021 06:29
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.

None yet

4 participants