elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
573 stars 205 forks source link

Make internal fields on DistributedTracingData public #2388

Open monty241 opened 5 days ago

monty241 commented 5 days ago

When self-handling traceparent, the use case we came across is the need to compare the transaction settings in Agent.Tracer.CurrentTransaction with the value of the traceparent HTTP header. The traceparent can be deserialized (and checked) using TryDeserializeFromString, but the members are internal only.

The use case is to use a generic class (filter) to more complex logic whether to create a new transaction when running distributed or hook on to the current transaction. Remember when service names are different, a new transaction can be attached to the parent span, whereas with equal service names this is not possible.

It would make it easier to compare TraceId, ParentId and TraceState between the current transaction and traceparent using the deserialized version acquired as an instance of DistributedTracingData when these fields would be readonly public.

Workaround is compare the string of traceparent and assume validity when TryDeserializeFromString returns a non null value.