Skip to content

http.server spans are incorrectly generated for non-2xx status codes when using OTel integration #5091

Description

@tvardero

Package

Sentry.OpenTelemetry

.NET Flavor

.NET Core

.NET Version

10.0.104

OS

Linux

OS Version

Fedora 43 Workstation

Development Environment

Rider 2025.x (Linux)

Other Error Monitoring Solution

No

Other Error Monitoring Solution Name

No response

SDK Version

6.2.0

Self-Hosted Sentry Version

25.11.0

Workload Versions

not applicable

UseSentry or SentrySdk.Init call

using OpenTelemetry.Trace;
using Sentry.OpenTelemetry;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();

builder.WebHost.UseSentry(c =>
{
    c.DisableSentryHttpMessageHandler = true;
    c.UseOpenTelemetry();
});

builder.Services.AddOpenTelemetry()
    .WithTracing(t =>
    {
        t.AddAspNetCoreInstrumentation();
        t.AddSentry();
    });

WebApplication app = builder.Build();

app.MapControllers();

app.Run();

Steps to Reproduce

  1. Create 2 endpoinds:
    • one returns 200, call it POST /GoodEndpoint
    • second throws an exception, call it POST /BadEndpoint
  2. Call them and examine traces in Sentry.

Expected Result

Endpoints that throws an exception should generate http.server transaction with POST /BadEndpoint name.
Failure rate for POST /BadEndpoint is 100%.

Actual Result

Endpoints that throws an exception generate http.server transaction with Microsoft.AspNetCore.Hosting.HttpRequestIn name.
Failure rate is POST /BadEndpoint is 0%, as all failures are recorded under Microsoft.AspNetCore.Hosting.HttpRequestIn.

This really prevents from analyzing what endpoint throws and what doesnt when looking at list of 100 endpoints. All of them have 0% failure rate, as all failures are collected under single Microsoft.AspNetCore.Hosting.HttpRequestIn.

Metadata

Metadata

Labels

.NETPull requests that update .net codeBugSomething isn't workingSpans

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions