-
Notifications
You must be signed in to change notification settings - Fork 774
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.AspNetCore] Fix issue causing Activity is not exported when used with custom propagator/sampler. #4637
[Instrumentation.AspNetCore] Fix issue causing Activity is not exported when used with custom propagator/sampler. #4637
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4637 +/- ##
==========================================
- Coverage 84.98% 84.96% -0.03%
==========================================
Files 314 314
Lines 12683 12685 +2
==========================================
- Hits 10779 10778 -1
- Misses 1904 1907 +3
|
Co-authored-by: Vishwesh Bankwar <vishweshbankwar@users.noreply.github.com>
@@ -95,6 +95,24 @@ public static object GetTagValue(this Activity activity, string tagName) | |||
return null; | |||
} | |||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |||
public static bool TryGetTagValue(this Activity activity, string tagName, out object tagValue) |
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 don't have to add a new method. We could use the existing method GetTagValue
: https://github.com/open-telemetry/opentelemetry-dotnet/pull/4637/files#diff-343f92e68a24f0d2d6ba9f91024a52f4f4b7085b5d30597dfec9303a07c14fc2R83
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.
How strongly do you feel about using the existing method?
I think the TryGet is cleaner and saves an unnecessary assertion (if returnValue != 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 think the min bar is:
- don't duplicate code (e.g. if we want to add this method, at least the existing one
GetTagValue
should be updated so it'll leverage theTryGetTagValue
). - keep it consistent - examine the existing usage and make proper update.
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.
saves an unnecessary assertion if (returnValue != null)
Even with the new method you have to check if (returnValue == true)
.
I would be in favor of reusing the existing method in this case and avoid having to introduce more code (and related tests) just to achieve a boolean
check instead of a null
check.
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 would be in favor of reusing the existing method in this case and avoid having to introduce more code (and related tests) just to achieve a
boolean
check instead of anull
check.
+1
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.
removed
Fixes #4626
When a custom propagator is used, the Instrumentation.AspNetCore library will create a new activity that is identified by a specific tag ("IsCreatedByInstrumentation").
For performance, only the first tag was inspected.
However, if a custom sampler is also used and adds tags that will affect the ordering and the instrumentation library will not identify the activity.
This causes activities to be dropped.
Changes
ActivityHelperExtensions.TryGetTagValue()
HttpInListener
to inspect all tags, not just first.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes