-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate sample rate through tracestate #1147
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
This commit propagates the sample rate of the APM agent through the tracestate header, and uses the sample rate received in incoming tracestate as the sample rate for non-root transactions and spans. Introduce TraceState type to model tracestate, allowing incoming headers to be added and sample rate to be set. Move TraceState validation from TraceContext onto TraceState. Obsolete TryDeserializeFromString and SerializeToString on DistributedTracingData in favour of a method that accepts both traceparent and tracestate, and properties that get the traceparent and tracestate text headers, respectively. Change Transaction and Span SampleRate to double? to allow a value to be omitted when incoming Trace context does not contain a tracestate header or the header does not contain the es vendor s attribute. Closes elastic#1021
8ea2adf
to
c8d3110
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a bit of a mixed feeling about adding [Obsolete()]
to the DistributedTracingData
public APIs.
For HTTP we propagate the tracestate
out of the box and I'm not sure how relevant it is to propagate this value manually for other use cases. I usually tend to prefer not to change public API. I'd totally agree with this PR if we'd start out new, but I'm not sure the benefit of adding the ability to propagate tracestate
manually outweighs technically breaking user code (sure, with the attribute we don't break directly, but long term users need to change user code).
I'll ask around on what other agents do.
In its current form, Let's sync to discuss. |
This commit removes the Obsolete attributes from DistributedTracingData, and does not expose Tracestate for now. Can evaluate again in future. When an activity is created when a transaction is started, use the tracestate from the activity, if present, but set the sample rate from the sampler and mutate tracestate if the es vendor is present. A transaction created without explicitly passed DistributedTracingData is considered to be a root transaction, so the sample rate is governed by the sampler.
Would you mind taking another look at this, @gregkalapos? I think it's good to go now, with the changes in 9c6d5f3, following our discussion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Just to document here one thing I was interested in and played with:
Activity
also propagates the traceparent
and tracestate
in HTTP requests - so it writes the exact same HTTP headers as we do. I did some testing and it seems that always our values end up being in those headers. We specifically check in HttpDiagnosticListenerImplBase.cs
if those hears are already present and only write those if they aren't. As it seems this is all fine and works as intended.
This commit propagates the sample rate of the APM agent through the tracestate header, and uses the sample rate received in incoming tracestate as the sample rate for non-root transactions and spans.
Introduce
TraceState
type to model tracestate, allowing incoming headers to be added and sample rate to be set. Move TraceState validation fromTraceContext
ontoTraceState
.Obsolete
TryDeserializeFromString
andSerializeToString
onDistributedTracingData
in favour of a method that accepts both traceparent and tracestate, and properties that get the traceparent and tracestate text headers, respectively.Change Transaction and Span SampleRate to
double?
to allow a value to be omitted when incoming Trace context does not contain a tracestate header or the header does not contain thees
vendors
attribute.Closes #1021