This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
If I run an app like below and call its API, the resulting span will be named Microsoft.AspNetCore.Hosting.HttpRequestIn and it will not be correlated with the trace from the app that called the API. The reason seems to be this piece of code from Microsoft.AspNetCore.Hosting.Internal.HostingApplicationDiagnostics:
if (_diagnosticListener.IsEnabled(ActivityStartKey))
{
_diagnosticListener.StartActivity(activity, new { HttpContext = httpContext });
}
The expected payload will be the HttpContext property of the actual payload, so context will be null.
Steps to Reproduce
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Resources;
using OpenTelemetry;
using OpenTelemetry.Trace;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using System;
class Program
{
public static async Task Main(string[] args)
{
var prefix = "http://localhost:999";
var host = WebHost
.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseHttpSys(x =>
{
x.UrlPrefixes.Add(prefix);
x.Authentication.AllowAnonymous = true;
})
.Build();
await host.StartAsync();
await Task.Delay(1000000);
}
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton(Sdk
.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder
.CreateDefault()
.AddService("TestService"))
.AddAspNetCoreInstrumentation()
.AddOtlpExporter()
.Build());
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc();
}
}
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
[HttpGet("Get")]
public void Get()
{
Console.WriteLine("Testing");
}
}
Expected Result
The span will be correctly named and correlated with its parent span.
Component
OpenTelemetry.Instrumentation.AspNetCore
Package Version
Runtime Version
net48
Description
If I run an app like below and call its API, the resulting span will be named Microsoft.AspNetCore.Hosting.HttpRequestIn and it will not be correlated with the trace from the app that called the API. The reason seems to be this piece of code from Microsoft.AspNetCore.Hosting.Internal.HostingApplicationDiagnostics:
if (_diagnosticListener.IsEnabled(ActivityStartKey)) { _diagnosticListener.StartActivity(activity, new { HttpContext = httpContext }); }
https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/4ee07f40efc5438816b718549fc99b6a0cdc3e1b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs#L95-L106
The expected payload will be the HttpContext property of the actual payload, so context will be null.
Steps to Reproduce
Expected Result
The span will be correctly named and correlated with its parent span.
Actual Result
It won't be
Additional Context
No response