-
Notifications
You must be signed in to change notification settings - Fork 283
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
[Instrumentation.AspNet] pass http.request.method to sampler #2023
base: main
Are you sure you want to change the base?
Conversation
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Cijo Thomas <[email protected]>
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Piotr Kiełkowicz <[email protected]>
{ | ||
tags = cachedTagsStorage ??= new KeyValuePair<string, object?>[1]; | ||
string? path = context.Request?.Unvalidated?.Path; | ||
string? method = context.Request?.HttpMethod; |
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 think we need to set the normalized value as we do here
If the method is normalized to _OTHER
then should we also include http.request.method_original, that part is not very clear in spec
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.
fixed 34e7fa3
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 think setting "HTTP" like the example you sent is the way to go. Keeping the convention.
@roycald245, one test is failing. |
I had some distractions recently. Will fix as soon as I'm able |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
- handle http method attributes as in RequestDataHelper.SetHttpMethodTag - fix cashing tags storage - extend tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2023 +/- ##
==========================================
+ Coverage 73.91% 77.32% +3.40%
==========================================
Files 267 15 -252
Lines 9615 366 -9249
==========================================
- Hits 7107 283 -6824
+ Misses 2508 83 -2425
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@roycald245, I have made some direct changes to
Please double check if you are fine with this solution. @cijothomas, could you please review? |
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.
LGTM
Need codeowner approval |
} | ||
|
||
Activity? activity = AspNetSource.StartActivity(TelemetryHttpModule.AspNetActivityName, ActivityKind.Server, propagationContext.ActivityContext, tags); | ||
tags.Add(new KeyValuePair<string, object?>(SemanticConventions.AttributeHttpRequestMethod, normalizedHttpMethod)); |
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.
-
We can probably remove this also being done in AspNet because sampler tags are automatically added to the span IIRC:
Line 77 in 32c4e94
this.requestDataHelper.SetHttpMethodTag(activity, originalHttpMethod); -
Consider refactoring this into
RequestDataHelper
something like this...
RequestDataHelper.SetHttpMethodTag(tags, originalHttpMethod: context.Request.HttpMethod);
class RequestDataHelper
{
public void SetHttpMethodTag(List<KeyValuePair<string, object?>> tags, string originalHttpMethod)
{
var normalizedHttpMethod = this.GetNormalizedHttpMethod(originalHttpMethod);
tags.Add(new(SemanticConventions.AttributeHttpRequestMethod, normalizedHttpMethod));
if (originalHttpMethod != normalizedHttpMethod)
{
tags.Add(new(SemanticConventions.AttributeHttpRequestMethodOriginal, originalHttpMethod));
}
}
}
Reason being it seems like all of this logic is already encapsulated inside RequestDataHelper
.
string? path = context.Request?.Unvalidated?.Path; | ||
string? originalHttpMethod = context.Request?.HttpMethod; |
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.
Is it possible for context
to be null
here?
string? path = context.Request?.Unvalidated?.Path; | |
string? originalHttpMethod = context.Request?.HttpMethod; | |
string? path = context.Request.Unvalidated?.Path; | |
string originalHttpMethod = context.Request.HttpMethod; |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
@roycald245, do you have some time to address @CodeBlanch comments? |
Fixes #57287
Changes
Added http.request.method to tags given to sampler
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes