Description
Issue with OpenTelemetry.Instrumentation.AspNet
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g. OpenTelemetry 1.3.2
):
<Reference Include="OpenTelemetry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.1.3.2\lib\net462\OpenTelemetry.dll</HintPath>
</Reference>
<Reference Include="OpenTelemetry.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.Api.1.3.2\lib\net462\OpenTelemetry.Api.dll</HintPath>
</Reference>
<Reference Include="OpenTelemetry.Exporter.Console, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.Exporter.Console.1.3.2\lib\net462\OpenTelemetry.Exporter.Console.dll</HintPath>
</Reference>
<Reference Include="OpenTelemetry.Extensions.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.Extensions.Hosting.1.0.0-rc9\lib\netstandard2.0\OpenTelemetry.Extensions.Hosting.dll</HintPath>
</Reference>
<Reference Include="OpenTelemetry.Instrumentation.AspNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.Instrumentation.AspNet.1.0.0-rc9.1\lib\net461\OpenTelemetry.Instrumentation.AspNet.dll</HintPath>
</Reference>
<Reference Include="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.1.0.0-rc9.1\lib\net461\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.dll</HintPath>
</Reference>
Runtime version (e.g. net462
, net48
, net6.0
, net7.0
etc. You can
find this information from the *.csproj
file):
net472
Is this a feature request or a bug?
- Feature Request
- Bug
What is the expected behavior?
- I Create an ASP NET Web Application and initialize OpenTelemetry this way:
IServiceCollection s = new ServiceCollection();
s.AddOpenTelemetryTracing(builder => {
builder.AddAspNetInstrumentation().AddConsoleExporter();
});
ServiceProvider serviceProvider = s.BuildServiceProvider();
var hostedServices = serviceProvider.GetServices<IHostedService>();
foreach (var hostedService in hostedServices)
{
_ = hostedService.StartAsync(CancellationToken.None);
}
- I set the traceparent in request header and sent to my application
- traceparent:00-6ea83d62e2dfba7068d3c046d04ae895-c52c52ddd45dfd29-01
- Activity started by AspNet Instrumentation should has parent and traceId should be set to
6ea83d62e2dfba7068d3c046d04ae895
What is the actual behavior?
** Possible reason:
I read the code of AspNet Instrumentation, found that the propagator of HttpTelemetryModule would be set to the
DefaultTextMapPropagator
, but once not initializing OpenTelemetry withSdk.AddOpentelemetryTracing()
, theDefaultTextMapPropagator
would be Noop instead ofCompositeTextMapPropagator
orTraceContextPropagator
.
Additional Context
I Set the
Sdk.SetDefaultTextMapPropagator(new CompositeTextMapPropagator(new TextMapPropagator[]
{
new TraceContextPropagator(),
new BaggagePropagator(),
}));
Then I get the expected behavior.
Is there any possibility that AspNet Intstrumentation would not rely on the default propagator? Or providing a way to reset the propagator specially for HttpTelemetryModule
?