-
Notifications
You must be signed in to change notification settings - Fork 820
[Exporter.Zipkin] Update remote endpoint and remove the peer.service attribute #6191
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
base: main
Are you sure you want to change the base?
[Exporter.Zipkin] Update remote endpoint and remove the peer.service attribute #6191
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6191 +/- ##
==========================================
+ Coverage 86.43% 86.56% +0.12%
==========================================
Files 258 258
Lines 11792 11834 +42
==========================================
+ Hits 10193 10244 +51
+ Misses 1599 1590 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
...OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityConversionExtensionsTest.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityConversionTests.cs
Show resolved
Hide resolved
...nTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityExporterRemoteEndpointTests.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs
Outdated
Show resolved
Hide resolved
Benchmark comparing new method CreateTestActivity and old method CreateTestActivity benchmark: CreateTestActivity taken from ZipkinActivitySource.cs
Results (testCase column was modified for better readability): The NewMethod is faster in the happy path, when you provide Highest Rank of Attribute "peer.service".
|
@TimothyMothra, @rajkumar-rangaraj, could you please review? |
|
||
private static PooledList<ZipkinAnnotation> ExtractActivityEvents(Activity activity) | ||
{ | ||
var annotations = PooledList<ZipkinAnnotation>.Create(); |
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.
There is a slight difference here: if the activity.EnumerateEvents()
is empty, the original code wouldn't create a PooledList
because the initialization (this.Annotations = PooledList<ZipkinAnnotation>.Create();
) in original code (link) is inside an if statement enumerator.MoveNext()
.
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 in bf03c84
|
||
// In the case when both activity status and status tag were set, | ||
// activity status takes precedence over status tag. | ||
else if (tagState.StatusCode.HasValue && tagState.StatusCode != StatusCode.Unset) |
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 the logic regarding tagState.StatusCode
removed? Was there any update on the rule in comment Error flag rule from https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/zipkin.md#status
?
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 logic for this has been moved to ExtractActivityStatus
. I'm using a different approach: I'm not adding the error and status tags in ExtractActivityTags
, and instead handling this in ExtractActivityStatus
.
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 old logic:
checks both activity status and status tag. Activity status takes precedence over status tag if both exist. Use status tag for StatusCode and StatusDescription if activity status is missing.
My question is the new logic never used StatusDescription from status tag like the old logic.
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 realized this activity.GetTagItem
is looking up in a LinkedList, so it does linear look up with O(n)
time complexity in the new logic. Then it'll eliminate performance benefits introduced by these new APIs: #6191 (comment).
This is likely why the existing approach would enumerate the tags and save the results into tagState
. This way the loop only happens once and we get all needed tag values (both StatusCode and StatusDescription) in one pass.
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 I understand your question about StatusDescription (error tag)
correctly: the specification states that StatusDescription
should not be set for OK
and UNSET
, and that part is accounted for. I'm also not trying to set StatusCode
to error just because StatusDescription
is present, since StatusCode
has higher priority.
If you're asking whether, in the case where Activity.Status
is UNSET
and StatusCode
is null
, and only a StatusDescription
is present - should we then set Activity.Status
and StatusCode
to error
based on that?
I think if Activity.Status
is UNSET
and StatusCode
is null
, we can treat the status as UNSET
, ignoring the fact that StatusDescription
is present.
The specification doesn't mention this particular case.
test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/RemoteEndpointPriorityTestCase.cs
Outdated
Show resolved
Hide resolved
return endpoint; | ||
} | ||
|
||
remoteEndpoint = activity.GetTagItem(SemanticConventions.AttributeHttpHost) as string; |
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 linked spec doesn't have this one. Is it kept for backward compatibility? If that's the case, maybe also keep a unit test case for 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.
Yes, this is kept for backward compatibility. Test added in bf03c84
{ | ||
foreach (ref readonly var tag in activity.EnumerateTagObjects()) | ||
if (activity.GetTagItem(SpanAttributeConstants.StatusCodeKey) is string status) |
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.
Mentioned in #6191 (comment): activity.GetTagItem
is a linear look up.
return null; | ||
} | ||
|
||
string? remoteEndpoint = activity.GetTagItem(SemanticConventions.AttributePeerService) as string; |
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.
See the other comment: #6191 (comment): activity.GetTagItem
is a linear look up.
Considering this action happens on every activity, it might be worth it to
- loop once like the old
EnumerateTags
to cache all the possible attributes forremoteEndpoint
and pick the highest ranking one (complexity is$O(n + k)$ ), rather than - do a loop for every possible attribute for
remoteEndpoint
(complexity is$O(k \cdot n + k)$ ).
(Assume the number of all the possible attributes for remoteEndpoint
is
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 cache all tags to avoid using Activity.GetTagItem
, not only in remoteEndpoint
but also in StatusCode
in this commit:2a0dacb
…com/ysolomchenko/opentelemetry-dotnet into remove-peer-service-resolver-zipkin
Fixes #6018
Changes
Removed the peer service resolver logic.
Extended remote endpoint calculation to align with the opentelemetry-specification.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changesChanges in public API reviewed (if applicable)