opentelemetry-dotnet-contrib
opentelemetry-dotnet-contrib copied to clipboard
[bug] No traces for AspNetCore instrumentation when AppService has CORS turned ON (traceparent header exists)
Component
OpenTelemetry.Instrumentation.AspNetCore
Package Version
Package Name | Version |
---|---|
OpenTelemetry.Instrumentation.AspNetCore | 1.9.0 |
OpenTelemetry | 1.9.0 |
OpenTelemetry.Exporter.OpenTelemetryProtocol | 1.9.0 |
Runtime Version
net8.0
Description
When deploying an application to Azure App Service with CORS enabled, traces generated by OpenTelemetry.Instrumentation.AspNetCore are not being created. Changing the exporter has no effect on this behavior. However, traces from other sources, such as EntityFrameworkCore and HttpClient instrumentation, are successfully exported.
The key difference between requests when CORS is enabled versus disabled in App Service is the presence of the traceparent header (e.g., traceparent: 00-63beafd20fc56a364971ebee560f6e9c-ad151c22e8fbe470-00). This header seems to be the likely cause of the missing traces when CORS is active.
Steps to Reproduce
- Create simple app that uses OpenTelemetry (e.g. from https://learn.microsoft.com/en-us/dotnet/core/diagnostics/observability-otlp-example)
- Add OpenTelemetry.Instrumentation.AspNetCore instrumentation
- Deploy application to AppService (my sample is deployed with docker image but I don't this it might affect)
- Go to API -> CORS -> Allowed Origins and put something here.
- Try to call API
When CORS is enabled, additional headers are introduced: traceparent: 00-63beafd20fc56a364971ebee560f6e9c-ad151c22e8fbe470-00 Content-Length: 0
You can see my sample app here https://github.com/wallyrion/OpenTelemetry.AppService.CorsIssue
Expected Result
I'm not sure about the expected behaviour here.
Actual Result
Http traces are not created and this is not obvious at all.
Additional Context
No response