Support for Enrich when using WithMetrics
Component
OpenTelemetry.Instrumentation.AspNetCore
Is your feature request related to a problem?
No response
What is the expected behavior?
When using AddAspNetCoreInstrumentation, there is no way to add Enrich using WithMetrics (as described here). It would be nice to have the possibility to update the activity so we can change the route according. My issue is that I am using version control and all the metrics are send out as "/api/v{version:apiVersion}" for the route name
builder.Services.AddOpenTelemetry().WithMetrics(opts => opts
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("A"))
.AddAspNetCoreInstrumentation()
.AddRuntimeInstrumentation()
.AddPrometheusExporter()
);
Updating the activity would allow us to change the route name from GET /api/v{version:apiVersion}/ to GET /api/v1/
I am using NET 8 with minimal API
Which alternative solutions or features have you considered?
Update the route automatically as describe there here
Additional context
No response
Maybe https://learn.microsoft.com/en-us/aspnet/core/log-mon/metrics/metrics?view=aspnetcore-8.0#enrich-the-aspnet-core-request-metric can solve your problem.
@splitt3r it is not possible to modify the built-in http.route