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

Scopes not being applied to Spans when using ASP.NET Core with OTel #3220

Closed
jamescrosswell opened this issue Mar 14, 2024 · 0 comments · Fixed by #3221
Closed

Scopes not being applied to Spans when using ASP.NET Core with OTel #3220

jamescrosswell opened this issue Mar 14, 2024 · 0 comments · Fixed by #3221

Comments

@jamescrosswell
Copy link
Collaborator

This code:

app.MapGet("/hello", async context =>
{
   SentrySdk.ConfigureScope(scope =>
   {
       scope.AddBreadcrumb("Saying hello...");
       scope.SetTag("Greeting", "Hello");
       using var task = SampleTelemetry.ActivitySource.StartActivity("Greet");
       task?.SetTag("Answer", 42);
       Thread.Sleep(100); // simulate some work
   });


   await context.Response.WriteAsync("Hey bro!");
});

Creates this trace:
image

Neither the Tags nor the Breadcrumbs flow through to Sentry.

This is because the _hub being resolved here is a HubAdapter rather than a plain old Hub:

if (activityScope is { } savedScope && _hub is Hub hub)
{
hub.RestoreScope(savedScope);
}

So that logic for resolving the Hub needs to be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant