Implement ISupportExternalScope
in SerilogLoggerProvider
#246
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.
Addresses the issue #245.
This adds support in the
SerilogLoggerProvider
for theISupportExternalScope
interface. TheMicrosoft.Extensions.Logging
library uses this interface when implemented to provide external scopes to logs. In practice, these scopes can include information about currentActivity
, such as the span ID, trace ID, tags, baggage, etc, which is configured by theActivityTrackingOptions
in theM.E.L
library.Support for tags and baggage via
ActivityTrackingOptions
was added in dotnet/runtime#48722.I've left in the sample app
SampleActivityLogging
which I used to confirm this was possible, which also demonstrates that this change works correctly with the rest ofM.E.L
and indeed logs out tags and baggage.If you were to run the
SampleActivityLogging
program before this change, you'd see the log lineAfter this change, this is now:
where the I've switched on all the available
ActivityTrackingOptions
.Outstanding questions
SpanId
andTraceId
on theLogEvent
, and logic in this library inSerilogLogger
to supply these values. I imagine we'd want to leave that alone for both backwards compatibility, and for users not usingM.E.L
? Instead, I think users should just not set those settings inActivityTrackingOptions
to avoid duplication.