opentelemetry-dotnet
opentelemetry-dotnet copied to clipboard
AspNet HttpInListener OnStopActivity is called after Activity is stopped by TelemetryHttpModule
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g. OpenTelemetry 1.0.2
):
- OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule 1.0.0-rc9.3
- OpenTelemetry.Instrumentation.AspNet 1.0.0-rc9.3
Runtime version:
- net48
Symptom
The "OpenTelemetry.Instrumentation.AspNet.Telemetry" span is processed and exported before it can be enriched by the the HttpInListener
and any custom Enrich
callbacks.
What is the expected behavior?
For example, the DisplayName of the Activity should be set to the MVC Route instead of the raw URL.
What is the actual behavior?
The DisplayName of the Activity remains the raw URL
Additional Context
In https://github.com/open-telemetry/opentelemetry-dotnet/blob/1.0.0-rc9.3/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs#L141, we can see that aspNetActivity.Stop();
is called before invoking the onRequestStoppedCallback
. That callback is responsible for calling into OnStopActivity
on HttpInListener
which can update the name based on the route template can call the Enrich
callback method.
I think that calling Stop()
on the activity automatically triggers the ActivityListeners, including processors and exporters, to handle when the Activity is stopped.
Is it as simple as moving Stop()
to after the callbacks?