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
SerilogLoggerProviderfor theISupportExternalScopeinterface. TheMicrosoft.Extensions.Logginglibrary 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 theActivityTrackingOptionsin theM.E.Llibrary.Support for tags and baggage via
ActivityTrackingOptionswas added in dotnet/runtime#48722.I've left in the sample app
SampleActivityLoggingwhich I used to confirm this was possible, which also demonstrates that this change works correctly with the rest ofM.E.Land indeed logs out tags and baggage.If you were to run the
SampleActivityLoggingprogram 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
SpanIdandTraceIdon theLogEvent, and logic in this library inSerilogLoggerto 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 inActivityTrackingOptionsto avoid duplication.