Skip to content

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

Closed
@jamescrosswell

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions