-
Notifications
You must be signed in to change notification settings - Fork 205
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
Implement config to ignore the sampled flag in traceparent #1310
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
Alternatives:
Maybe make it
|
@gregkalapos, @AlexanderWert Another alternative, which is along similar lines to ones proposed: New configuration value: If
The end result is that sampled flag value of 0 is ignored when tracestate does not contain |
@russcam the suggestion sounds good to me. The advantage is clearly that this would solve the issues we have with .NET5+ unmonitored services while it causes the least harm in other environments. The only disadvantage I see is that people will have a super hard time to understand this - I don't expect users to understand the W3C TraceContext spec, so it'll be super hard to explain in the docs what this config exactly does. Overall I think this is a good way to proceed and worth accepting the more complicated setting - I'll update the PR. |
Pushed the changes discussed above - ready for another review round. |
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've had an initial look and left some comments
@@ -32,6 +32,7 @@ public static class DefaultValues | |||
public const string SpanFramesMinDuration = "5ms"; | |||
public const double SpanFramesMinDurationInMilliseconds = 5; | |||
public const int StackTraceLimit = 50; | |||
public const bool SuppressTraceContextHeaders = false; |
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.
public const bool SuppressTraceContextHeaders = false; | |
public const bool TraceContextIgnoreSampledFalse = false; |
Consistent name for the default value constant
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.
👍 Fixed this and the usage of it as well.
docs/configuration.asciidoc
Outdated
[[config-trace-context-ignore-sampled-false]] | ||
==== `TraceContextIgnoreSampledFalse` | ||
|
||
By setting this to `true` the agent will ignore the sampled part of the W3C TraceContext traceparent header when it's false and when the upstream transaction is not coming from a non-Elastic APM agent. |
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.
It might be useful to explain the "normal" flow when Trace Context is received, and then lead into describing what this setting does. In doing so, I think it would provide more context around why it is needed and if it might be relevant to a specific user.
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.
Done
docs/configuration.asciidoc
Outdated
This can be useful when a caller service always sets the sampled flag to false and the agent would have no chance to | ||
create any sampled transaction. | ||
|
||
NOTE: .NET 5 by default sets the W3C TraceContext headers, but without an active agent it sets the sampled flag to `false` leading to 0% sampling. If your service is called by an unmonitored .NET 5 application, setting this flag will instruct the agent to start a new trace and make a new sampling decision based on <<config-transaction-sample-rate>>. |
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.
NOTE: .NET 5 by default sets the W3C TraceContext headers, but without an active agent it sets the sampled flag to `false` leading to 0% sampling. If your service is called by an unmonitored .NET 5 application, setting this flag will instruct the agent to start a new trace and make a new sampling decision based on <<config-transaction-sample-rate>>. | |
[IMPORTANT] | |
-- | |
.NET 5 applications set the https://www.w3.org/TR/trace-context/[W3C Trace Context] headers for outgoing HTTP requests by default, but with the traceparent sampled flag set to `false`. If the application has an active agent, the agent will ensure that the sampled flag is propagated appropriately. If the application does not have an active agent however, and the application calls another application (the callee) that does have an active agent, the propagation of a sampled flag of `false` results in no sampled traces in the callee application. | |
If your application is called by an unmonitored .NET 5 application, setting `TraceContextIgnoreSampledFalse` to `true` will instruct the agent to start a new trace and make a new sampling decision based on <<config-transaction-sample-rate>> when the traceparent sampled flag is `false` and there is no agent specific tracestate present. | |
-- |
Maybe the section should lead with this?
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.
Sounds good, moved this to the top of the section.
docs/configuration.asciidoc
Outdated
|
||
[IMPORTANT] | ||
-- | ||
..NET 5 applications set the https://www.w3.org/TR/trace-context/[W3C Trace Context] headers for outgoing HTTP requests by default, but with the traceparent sampled flag set to `false`. If the application has an active agent, the agent will ensure that the sampled flag is propagated appropriately. If the application does not have an active agent however, and the application calls another application (the callee) that does have an active agent, the propagation of a sampled flag of `false` results in no sampled traces in the callee application. |
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.
It seems we need an additional .
to render .NET
in asciidoc when it's the 1. word in the section.
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.
This looks like it renders the paragraph in red italics in asciidoctor.js
An attribute entry can be used
..NET 5 applications set the https://www.w3.org/TR/trace-context/[W3C Trace Context] headers for outgoing HTTP requests by default, but with the traceparent sampled flag set to `false`. If the application has an active agent, the agent will ensure that the sampled flag is propagated appropriately. If the application does not have an active agent however, and the application calls another application (the callee) that does have an active agent, the propagation of a sampled flag of `false` results in no sampled traces in the callee application. | |
:dot: . | |
{dot}NET 5 applications set the https://www.w3.org/TR/trace-context/[W3C Trace Context] headers for outgoing HTTP requests by default, but with the traceparent sampled flag set to `false`. If the application has an active agent, the agent will ensure that the sampled flag is propagated appropriately. If the application does not have an active agent however, and the application calls another application (the callee) that does have an active agent, the propagation of a sampled flag of `false` results in no sampled traces in the callee application. |
which renders as
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.
Can ignore the suggestion here as it's included in the next suggestion
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. I've left a suggestion for the docs
docs/configuration.asciidoc
Outdated
|
||
[IMPORTANT] | ||
-- | ||
..NET 5 applications set the https://www.w3.org/TR/trace-context/[W3C Trace Context] headers for outgoing HTTP requests by default, but with the traceparent sampled flag set to `false`. If the application has an active agent, the agent will ensure that the sampled flag is propagated appropriately. If the application does not have an active agent however, and the application calls another application (the callee) that does have an active agent, the propagation of a sampled flag of `false` results in no sampled traces in the callee application. |
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.
Can ignore the suggestion here as it's included in the next suggestion
Turned SuppressTraceContextHeaders into TraceContextIgnoreSampledFalse.
Co-authored-by: Russ Cam <[email protected]>
The problem
We started seeing environments where the full trace is not within elastic and the sample rate is effectively 0% regardless of the
TransactionSampleRate
setting. Very likely this is because unmonitored .NET5+ services send atraceparent
header with a sampled flag set to0
(doc on the change from Microsoft)Proposed solution in this PR
We add a new setting calledUpdate: see comments below, the solution evolved during the PR reviews.SuppressTraceContextHeaders
. If this istrue
we ignore any distributed tracing data during transaction start and we make a new sampling decision regardless of thetraceparent
value.