Open CodeBlanch opened 8 months ago
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti See info in area-owners.md if you want to be subscribed.
Author: | CodeBlanch |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Diagnostics.Tracing`, `untriaged` |
Milestone: | - |
Note that, this proposal will increase the ActivityContext size which I guess it is used a lot especially ActivitContext is a struct which is possible get copied in some scenarios. You are not concerned about this?
I marked this to future and we can get it back to current release if we see a demand need it soon.
Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity See info in area-owners.md if you want to be subscribed.
Author: | CodeBlanch |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `untriaged`, `area-System.Diagnostics.Activity` |
Milestone: | Future |
Background and motivation
OpenTelemetry .NET's propagation API is centered around
ActivityContext
. Anytime we need to propagate a span/Activity
(for example outgoing http call) we generate a W3Ctraceparent
:https://github.com/open-telemetry/opentelemetry-dotnet/blob/ef942a11ac264d7b0f754a78dd3b4dd7d4d2c6f3/src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs#L116-L121
This is a string allocation and takes some CPU cycles.
If a trace is NOT sampled, we create a single root span/
Activity
. That root span/Activity
may be propagated many times servicing a request (if it calls a lot of downstream services). In that case we're going to be generating the same string each time.The idea here is basically a performance optimization.
Activity
has this Id property which is the same W3Ctraceparent
as what OTel is building, but it is cached so subsequent calls don't incur the perf hit to generate it.The goal here is to expose that same
Id
onActivityContext
and utilize the cache mechanism where we can.Proof of concept diff: https://github.com/dotnet/runtime/compare/main...CodeBlanch:activitycontext-id?expand=1
API Proposal
API Usage
Alternative Designs
No response
Risks
No response