Support the http.request.method_original attribute#8779
Conversation
| this( | ||
| httpAttributesGetter, | ||
| netAttributesGetter, | ||
| capturedRequestHeaders, | ||
| capturedResponseHeaders, | ||
| knownMethods, | ||
| HttpRouteHolder::getRoute); |
There was a problem hiding this comment.
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.
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.
| 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.
I really dislike these nulls 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.
breedx-splk
left a comment
There was a problem hiding this comment.
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.
static import the names to improve readability?
There was a problem hiding this comment.
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.
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.
| * @param knownMethods A set of recognized HTTP request methods. | ||
| */ | ||
| @CanIgnoreReturnValue | ||
| public OkHttpTelemetryBuilder setKnownMethods(Set<String> knownMethods) { |
There was a problem hiding this comment.
@Nullable on the param?
There was a problem hiding this comment.
Collections should never be nullable in the API (see the comment above)
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.
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.methodattribute to_OTHERand, except if reporting a metric, MUST set the exact method received in the request line as value of thehttp.request.method_originalattribute.
There was a problem hiding this comment.
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.
🤷
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.
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.
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.
(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.
trask
left a comment
There was a problem hiding this comment.
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