-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Logging.EventSource] Add trace correlation fields #103655
Merged
tarekgh
merged 6 commits into
dotnet:main
from
CodeBlanch:logging-eventsource-correlationfields
Jun 22, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ec5342
Add trace correlation fields to Microsoft.Extensions.Logging.EventSou…
CodeBlanch e68e9a5
Code review.
CodeBlanch 0e968ae
Code review.
CodeBlanch dc52eb9
Merge remote-tracking branch 'upstream/main' into logging-eventsource…
CodeBlanch 26a9b90
Merge remote-tracking branch 'upstream/main' into logging-eventsource…
CodeBlanch e69bc64
Test fix.
CodeBlanch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we sure we don't want support non W3C cases too?
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.
Well for non-W3C TraceId is going to spit out
00000000000000000000000000000000
and SpanId is going to spit out0000000000000000
. We could just pushActivity.Id
into the events which would includeW3C
,Hierarchical
, and (presumably) anything added in the future. BUT. AccessingActivity.Id
will force an allocation in the process being monitored. And it will force consumers to have to inspect the value and understand the possible formats/differences. Probably also the consumers will have to chop up theId
into the individual components. In my world of OTel I don't need hierarchical but if you feel there is a need and the tradeoffs are OK, I'm happy to switch it.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 have been supporting the
Hierarchical
cases with external logger scopes.runtime/src/libraries/Microsoft.Extensions.Logging/src/LoggerFactoryScopeProvider.cs
Line 291 in b93061a
Also, will it make sense to add the parent Id to the event as we do in scopes?
CC @noahfalk if he has more insight if we should ignore the
Hierarchical
cases or not.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.
Just FYI the reason I went with
ActivityTraceId
,ActivitySpanId
, andActivityTraceFlags
is because those are the only things defined on the OTel Logs Data Model for correlation: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#log-and-event-record-definitionHappy to add other things, but from OTel perspective they aren't required.
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'd be fine omitting support for hierarichal. Worst case I forsee is we get feedback that someone wants Hierarichal support, we decide the scenario in the request is important and then we add that too in a future release. I think that has a pretty low chance of happening.