-
Notifications
You must be signed in to change notification settings - Fork 870
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
Support the http.request.method_original
attribute
#8779
Support the http.request.method_original
attribute
#8779
Conversation
this( | ||
httpAttributesGetter, | ||
netAttributesGetter, | ||
capturedRequestHeaders, | ||
capturedResponseHeaders, | ||
knownMethods, | ||
HttpRouteHolder::getRoute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complexity of these constructors is kinda starting to get out of hand; I'm planning to implement Jason's dependency injection comment once I merge all the in-flight PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this constructor is called all over the place with the default set, you might (in the short term) also consider doing a constructor overload that defaults the set. I think that applies to the client attr extractor as well.
@@ -24,6 +26,7 @@ public final class OkHttpTelemetryBuilder { | |||
new ArrayList<>(); | |||
private List<String> capturedRequestHeaders = emptyList(); | |||
private List<String> capturedResponseHeaders = emptyList(); | |||
@Nullable private Set<String> knownMethods = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike these null
s here; but this was the least invasive way of implementing an optionally unset set of methods. I've an idea on how to refactor these, but I'll tackle that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me, just had a few small ideas. Thanks!
if (knownMethods.contains(method)) { | ||
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); | ||
} else { | ||
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static import the names to improve readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HttpAttributes
values? I'm in favor of that actually -- but if we're doing that, we should implement it for all attribute keys across the whole package. I think I'd prefer to make it a separate PR, if you don't mind
this( | ||
httpAttributesGetter, | ||
netAttributesGetter, | ||
capturedRequestHeaders, | ||
capturedResponseHeaders, | ||
knownMethods, | ||
HttpRouteHolder::getRoute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this constructor is called all over the place with the default set, you might (in the short term) also consider doing a constructor overload that defaults the set. I think that applies to the client attr extractor as well.
...ry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java
Outdated
Show resolved
Hide resolved
...ry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java
Outdated
Show resolved
Hide resolved
...ry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorStableSemconvTest.java
Outdated
Show resolved
Hide resolved
...brary/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/server/KtorServerTracing.kt
Show resolved
Hide resolved
...elemetry/instrumentation/netty/v4/common/internal/server/NettyServerInstrumenterFactory.java
Show resolved
Hide resolved
* @param knownMethods A set of recognized HTTP request methods. | ||
*/ | ||
@CanIgnoreReturnValue | ||
public OkHttpTelemetryBuilder setKnownMethods(Set<String> knownMethods) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nullable
on the param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collections should never be nullable in the API (see the comment above)
...java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxTelemetryBuilder.java
Show resolved
Hide resolved
...-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/CommonConfig.java
Outdated
Show resolved
Hide resolved
b350a13
to
4e07ef2
Compare
@open-telemetry/java-instrumentation-approvers please review this PR 🙏 |
asList( | ||
"CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"))); | ||
|
||
public static final String _OTHER = "_OTHER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was chosen because it makes the "other" default value look like it's a kinda special thing (which it is)
If the HTTP request method is not known to instrumentation, it MUST set the
http.request.method
attribute to_OTHER
and, except if reporting a metric, MUST set the exact method received in the request line as value of thehttp.request.method_original
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it comes from the spec then so it must be. In my opinion using _OTHER
is a mistake, there is no way that this is not going to confuse users. Everybody who sees it will assume that this is a bug/typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷
I don't really have a strong opinion on the value itself; I do agree that you need to have some sort of indication that it's some other unrecognized value though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably the most relevant comment why _OTHER
was chosen: open-telemetry/semantic-conventions#17 (comment)
I could see backends potentially displaying this metric value with a special tooltip to help ease user confusion
public NettyServerTelemetryBuilder setKnownMethods(Set<String> knownMethods) { | ||
this.knownMethods = knownMethods; | ||
return this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make any sense to have HttpClientTelemetryBuilder
interface to help enforce that these implementations are consistent (and maybe we can inherit javadoc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and maybe we can inherit javadoc)?
Hmm, we can put a @see
tag I think. I don't think we can actually enforce that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open an issue to add common http client/server tests which exercise the non-standard methods (I don't think it's a high priority since it's an edge case anyways)
Implements open-telemetry/semantic-conventions#17