Skip to content

Commit 4559163

Browse files
Clarified that agent MUST include sample_rate in transactions and spans (#480)
* Clarified that agent MUST include sample_rate in transactions and spans * Qualified that sample_rate must be included only when it's available * Rephrase not to imply that there might be more than one case Rephrase not to imply that there might be more than one case when sampling rate is not available * Update specs/agents/tracing-sampling.md Co-authored-by: Colton Myers <[email protected]> * Uppercase relevant occurrences of "must" Co-authored-by: Colton Myers <[email protected]>
1 parent bd68b16 commit 4559163

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

specs/agents/tracing-sampling.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ Metrics will be more accurate when the sampling rate is high.
6363
With lower sampling rates the server is able to calculate representative, but less accurate, metrics.
6464
If the sampling rate is 0 then no metrics will be calculated at all.
6565

66-
Agents will record the sampling rate on transactions and spans as `sample_rate`. e.g.
66+
When the sampling rate is available Agents MUST record the sampling rate on transactions and spans as `sample_rate`, e.g.
6767

6868
{"transaction":{"name":"GET /","sample_rate":0.1,...}}
6969
{"span":{"name":"SELECT FROM table","sample_rate":0.1,...}}
7070

71-
For non-sampled transactions the `sample_rate` field _must_ be set to 0,
71+
See [Propagation section of this document](#propagation) for details about the case when the sampling rate is not available.
72+
73+
For non-sampled transactions the `sample_rate` field MUST be set to 0,
7274
to ensure non-sampled transactions are not counted in transaction metrics.
7375
This is important to avoid double-counting,
7476
as non-sampled transactions will be represented in metrics calculated from sampled transactions.
@@ -98,7 +100,7 @@ In the future we may introduce options to agents to stop sending non-sampled tra
98100
As mentioned above, the sampling decision must be propagated throughout the trace.
99101
We adhere to the W3C Trace-Context spec for this, propagating the decision through trace-flags: https://www.w3.org/TR/trace-context/#sampled-flag
100102

101-
In addition to propagating the sampling decision (boolean), agents must also propagate the sampling rate to ensure it is consistently attached to to all events in the trace.
103+
In addition to propagating the sampling decision (boolean), agents MUST also propagate the sampling rate to ensure it is consistently attached to to all events in the trace.
102104
This is achieved by adding an `s` attribute to our [`es` `tracestate` key](tracing-distributed-tracing.md#tracestate) with the value of the sampling rate.
103105
e.g.
104106

@@ -107,7 +109,7 @@ e.g.
107109
As `tracestate` has modest size limits we must keep the size down.
108110
This is ensured as the `transaction_sample_rate` configuration option has a maximum precision of 4 decimal places.
109111

110-
For non-root transactions the agent must parse incoming `tracestate` headers to identify the `es` entry and extract the `s` attribute.
112+
For non-root transactions the agent MUST parse incoming `tracestate` headers to identify the `es` entry and extract the `s` attribute.
111113
The `s` attribute value should be used to populate the `sample_rate` field of transactions and spans.
112114
If there is no `tracestate` or no valid `es` entry with an `s` attribute,
113-
then the agent must omit `sample_rate` from non-root transactions and their spans.
115+
then the agent MUST omit `sample_rate` from non-root transactions and their spans.

0 commit comments

Comments
 (0)