You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EventSourceLogger does not propagate SpanId and TraceId #76718
Asp.net log scope data collected from an out of process collector such as dotnet-monitor no longer contains Activity information such as TraceId and SpanId. These properties are no longer added as part of the Request scope data (see dotnet/aspnetcore#22376). These properties are no added to loggers using IExternalScopeProvider/ISupportExternalScope, which EventSourceLogger does not support.
Create a new asp.net core 6.0 web application.
Install dotnet-monitor tool
Run dotnet-monitor collect --no-auth
Run curl https://localhost:52323/logs?level=Information&pid=<pid of web app>
Issue a request to the web app.
Expected behavior
Log from dotnet-monitor should contain SpanId and TraceId information
Actual behavior
Log entry contains RequestId and RequestPath, but no activity information is displayed.
It may be a good idea to implement ISupportExternalScope on EventSourceLoggerProvider as a perf improvement but I think for correlation what we should do is add TraceId, SpanId, and ActivityTraceFlags from Activity.Current as fields on the events emitted by LoggingEventSource.
The reason is, users may not want scopes. In OTel we don't recommend scopes at all. Users who have enabled scopes have complained about the amount of data that appears because AspNetCore creates some scopes automatically.
Also I think we might want to try and get this into .NET 9. We're working on solving out of process monitoring and correlation is very important to that scenario.
Activity
CodeBlanch commentedon May 30, 2024
@tarekgh @noahfalk @samsp-msft
It may be a good idea to implement
ISupportExternalScopeonEventSourceLoggerProvideras a perf improvement but I think for correlation what we should do is addTraceId,SpanId, andActivityTraceFlagsfromActivity.Currentas fields on the events emitted byLoggingEventSource.The reason is, users may not want scopes. In OTel we don't recommend scopes at all. Users who have enabled scopes have complained about the amount of data that appears because AspNetCore creates some scopes automatically.
Why
TraceId,SpanId, andActivityTraceFlags? From an OTel perspective those are the trace context fields added to logs for correlation: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#log-and-event-record-definitionAlso I think we might want to try and get this into .NET 9. We're working on solving out of process monitoring and correlation is very important to that scenario.