Skip to content

Separate HTTP client/server AttributesExtractors#4195

Merged
trask merged 1 commit intoopen-telemetry:mainfrom
mateuszrzeszutek:separate-http-client-server-attributes-extractors
Sep 24, 2021
Merged

Separate HTTP client/server AttributesExtractors#4195
trask merged 1 commit intoopen-telemetry:mainfrom
mateuszrzeszutek:separate-http-client-server-attributes-extractors

Conversation

@mateuszrzeszutek
Copy link
Copy Markdown
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

*
* @see DbAttributesExtractor
* @see HttpAttributesExtractor
* @see HttpClientAttributesExtractor
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants