Skip to content
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

EventSourceLogger does not propagate SpanId and TraceId #76718

Closed
Tracked by #77390
wiktork opened this issue Oct 6, 2022 · 3 comments · Fixed by #103655
Closed
Tracked by #77390

EventSourceLogger does not propagate SpanId and TraceId #76718

wiktork opened this issue Oct 6, 2022 · 3 comments · Fixed by #103655
Labels
area-Extensions-Logging in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@wiktork
Copy link
Member

wiktork commented Oct 6, 2022

Description

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.

Related dotnet-monitor issue dotnet/dotnet-monitor#2545

Reproduction Steps

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.

Regression?

Yes; this behavior worked in 3.1

Known Workarounds

No response

Configuration

Windows .Net 6 x64

The issue is specific to net 6+.

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 6, 2022
@ghost
Copy link

ghost commented Oct 6, 2022

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

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.

Related dotnet-monitor issue dotnet/dotnet-monitor#2545

Reproduction Steps

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.

Regression?

Yes; this behavior worked in 3.1

Known Workarounds

No response

Configuration

Windows .Net 6 x64

The issue is specific to net 6+.

Other information

No response

Author: wiktork
Assignees: -
Labels:

untriaged, area-Extensions-Logging

Milestone: -

@tarekgh tarekgh added this to the 8.0.0 milestone Oct 6, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 6, 2022
@tarekgh tarekgh modified the milestones: 8.0.0, 9.0.0 Jul 25, 2023
@tarekgh tarekgh modified the milestones: 9.0.0, Future Nov 20, 2023
@CodeBlanch
Copy link
Contributor

@tarekgh @noahfalk @samsp-msft

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.

Why TraceId, SpanId, and ActivityTraceFlags? 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-definition

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.

@tarekgh tarekgh modified the milestones: Future, 9.0.0 Jun 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Jun 18, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Logging in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants