Skip to content

Commit 4f4e3fa

Browse files
committed
add TBS policy example to explain service order
1 parent 0847863 commit 4f4e3fa

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

solutions/observability/apm/transaction-sampling.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Trace events are matched to policies in the order specified. Each policy list mu
272272
Note that from version `9.0.0` APM Server has an unlimited storage limit, but will stop writing when the disk where the database resides reaches 80% usage. Due to how the limit is calculated and enforced, the actual disk space may still grow slightly over this disk usage based limit, or any configured storage limit.
273273
::::
274274

275-
### Example configuration [_example_configuration]
275+
### Example configuration A [_example_configuration_a]
276276

277277
This example defines three tail-based sampling polices:
278278

@@ -290,6 +290,20 @@ This example defines three tail-based sampling polices:
290290
2. Samples 1% of traces in `production` with the trace name `"GET /not_important_route"`
291291
3. Default policy to sample all remaining traces at 10%, e.g. traces in a different environment, like `dev`, or traces with any other name
292292

293+
### Example configuration B [_example_configuration_b]
294+
295+
For a trace that originates in Service A and ends in Service B without error, what would the sampling be?
296+
297+
```yaml
298+
- sample_rate: 0.3
299+
service.name: B
300+
- sample_rate: 0.5
301+
service.name: A
302+
- sample_rate: 1.0 # Always set a default
303+
```
304+
305+
In the example, only 50% of traces will be sampled. The service that start the trace (Service A) has precedence over child services (Service B). The order of services does not matter, what matters, is in what service the trace event start. Service A, is were the trace starts, and therefore will always have precedence over "child" services that only create spans (Service B). If we start at Service B instead, pass on the context to Service A, which then adds a child span, then, the policy of `service.name: B` will take precedence over that of `service.name: A`. This is because we are working on the *trace level* rather than the *service level*.
306+
293307
### Configuration reference [_configuration_reference]
294308

295309
#### Top-level tail-based sampling settings [_top_level_tail_based_sampling_settings]

0 commit comments

Comments
 (0)