HTTP OPTIONS request , transaction name(display name) is shown as request path instead of HTTP route ( template ) in asp.net core api app
Bug Report
HTTP OPTIONS request, transaction name(display name) is shown as request path instead of HTTP route ( template ) in asp.net core api app
Expected transaction name(display name) : Todo/{tenantid}/{version} What is shown is : /todo/456-123-56abc-x134/2022-02-01
It seems to happen for HTTP OPTIONS request ,like browser HTTP OPTIONS pre-flight request to check the CORS.
List of all OpenTelemetry NuGet
packages](https://www.nuget.org/profiles/OpenTelemetry) and version that you are
using (e.g. OpenTelemetry 1.0.2):
ASP.NET Core 3.1 , Windows 10 Zipkin & Console exporter is configured
OTel version
- OpenTelemetry.Exporter.Zipkin1.1.0
- OpenTelemetry.Instrumentation.AspNetCore 1.0.0-rc7
- OpenTelemetry.Extensions.Hosting 1.0.0-rc7
- System.Diagnostics.DiagnosticSource 5.0.1
Runtime version :
ASP.NET Core 3.1 , Windows 10
Symptom
For HTTP OPTIONS request, transaction name(display name) is shown as request path instead of HTTP route ( template ) in asp.net core api app
What is the expected behavior?
Expected transaction name (display name): Todo/{tenantid}/{version}
What is the actual behavior?
What is shown is : /todo/456-123-56abc-x134/2022-02-01
Reproduce
Any ASP.NET Core 3.1 API app with above packages & send HTTP OPTIONS request ,like browser HTTP OPTIONS pre-flight request to check the CORS. POST request
curl -v -X POST http://localhost:5000/todo/456-123-56abc-x134/2022-02-01 -d {}
OPTIONS request
curl -v -X OPTIONS http://localhost:5000/todo/456-123-56abc-x134/2022-02-01 -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: content-type" -H "Origin: https://reqbin.com" -d {}
C# Sample
// curl -v -X OPTIONS http://localhost:5000/todo/456-123-56abc-x134/2022-02-01 -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: content-type" -H "Origin: https://reqbin.com" -d {}
// curl -v -X POST http://localhost:5000/todo/456-123-56abc-x134/2022-02-01 -d {}
[Route("[controller]")]
[ApiController]
public class TodoController : ControllerBase
{
static HttpClient httpClient = new HttpClient();
private readonly ActivitySource activitySource;
private readonly ILogger<TodoController> _logger;
public TodoController(ILogger<TodoController> logger,ActivitySource activitySource)
{
this.activitySource = activitySource;
this._logger = logger;
}
[HttpPost]
[Route("{tenantid}/{version}")]
public IActionResult Create(string tenantid, string version)
{
Console.WriteLine($"{nameof(tenantid)}={tenantid},{nameof(version)}={version}");
using (activitySource.StartActivity("Calling external Service"))
{
_logger.LogInformation("TodoController:Get Calling external service");
InvokeExternalService();
}
return Ok();
}
public void InvokeExternalService()
{
try
{
httpClient.GetStringAsync("http://www.google.com").GetAwaiter().GetResult();
}
catch (Exception exp)
{
// Console.WriteLine(exp);
throw;
}
}
}
We will close this issue if:
- The repro project you share with us is complex. We can't investigate custom projects, so don't point us to such, please.
- If we can not reproduce the behavior you're reporting.
Additional Context


Add any other context about the problem here.
We have api versioning for our endpoints which .net supports so for example: [Route("api/v{apiVersion:apiVersion}/[controller]")] which is being reported as api/v{apiVersion:apiVersion}/users which is not really what we would like to achieve...
In that case it would be actually nice to see api/v1/users as a transaction name
Other thread: https://github.com/open-telemetry/opentelemetry-dotnet/issues/4525