Skip to content

Commit 68b9632

Browse files
[apm serverless] Add examples using trace_continuation_strategy to sampling docs (#4210)
* port #4167 to serverless * Update docs/en/serverless/apm/apm-transaction-sampling.mdx Co-authored-by: DeDe Morton <[email protected]> --------- Co-authored-by: DeDe Morton <[email protected]>
1 parent 2cef44f commit 68b9632

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

docs/en/serverless/apm/apm-transaction-sampling.mdx

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,69 @@ Head-based sampling is quick and easy to set up.
2828
Its downside is that it's entirely random &mdash; interesting
2929
data might be discarded purely due to chance.
3030

31-
### Distributed tracing with head-based sampling
31+
### Distributed tracing
3232

3333
In a _distributed_ trace, the sampling decision is still made when the trace is initiated.
3434
Each subsequent service respects the initial service's sampling decision, regardless of its configured sample rate;
3535
the result is a sampling percentage that matches the initiating service.
3636

37-
In this example, `Service A` initiates four transactions and has sample rate of `.5` (`50%`).
38-
The sample rates of `Service B` and `Service C` are ignored.
37+
In the example in _Figure 1_, `Service A` initiates four transactions and has a sample rate of `.5` (`50%`).
38+
The upstream sampling decision is respected, so even if the sample rate is defined and is a different
39+
value in `Service B` and `Service C`, the sample rate will be `.5` (`50%`) for all services.
40+
41+
**Figure 1. Upstream sampling decision is respected**
3942

4043
![Distributed tracing and head based sampling example one](../images/apm-dt-sampling-example-1.png)
4144

42-
In this example, `Service A` initiates four transactions and has a sample rate of `1` (`100%`).
43-
Again, the sample rates of `Service B` and `Service C` are ignored.
45+
In the example in _Figure 2_, `Service A` initiates four transactions and has a sample rate of `1` (`100%`).
46+
Again, the upstream sampling decision is respected, so the sample rate for all services will
47+
be `1` (`100%`).
48+
49+
**Figure 2. Upstream sampling decision is respected**
4450

4551
![Distributed tracing and head based sampling example two](../images/apm-dt-sampling-example-2.png)
4652

47-
### OpenTelemetry with head-based sampling
53+
### Trace continuation strategies with distributed tracing
54+
55+
In addition to setting the sample rate, you can also specify which _trace continuation strategy_ to use.
56+
There are three trace continuation strategies: `continue`, `restart`, and `restart_external`.
57+
58+
The **`continue`** trace continuation strategy is the default and will behave similar to the examples in
59+
the [Distributed tracing section](#distributed-tracing).
60+
61+
Use the **`restart_external`** trace continuation strategy on an Elastic-monitored service to start
62+
a new trace if the previous service did not have a `traceparent` header with `es` vendor data.
63+
This can be helpful if a transaction includes an Elastic-monitored service that is receiving requests
64+
from an unmonitored service.
65+
66+
In the example in _Figure 3_, `Service A` is an Elastic-monitored service that initiates four transactions
67+
with a sample rate of `.25` (`25%`). Because `Service B` is unmonitored, the traces started in
68+
`Service A` will end there. `Service C` is an Elastic-monitored service that initiates four transactions
69+
that start new traces with a new sample rate of `.5` (`50%`). Because `Service D` is also
70+
Elastic-monitored service, the upstream sampling decision defined in `Service C` is respected.
71+
The end result will be three sampled traces.
72+
73+
**Figure 3. Using the `restart_external` trace continuation strategy**
74+
75+
![Distributed tracing and head based sampling with restart_external continuation strategy](../images/apm-dt-sampling-continuation-strategy-restart_external.png)
76+
77+
Use the **`restart`** trace continuation strategy on an Elastic-monitored service to start
78+
a new trace regardless of whether the previous service had a `traceparent` header.
79+
This can be helpful if an Elastic-monitored service is publicly exposed, and you do not
80+
want tracing data to possibly be spoofed by user requests.
81+
82+
In the example in _Figure 4_, `Service A` and `Service B` are Elastic-monitored services that use the
83+
default trace continuation strategy. `Service A` has a sample rate of `.25` (`25%`), and that
84+
sampling decision is respected in `Service B`. `Service C` is an Elastic-monitored service that
85+
uses the `restart` trace continuation strategy and has a sample rate of `1` (`100%`).
86+
Because it uses `restart`, the upstream sample rate is _not_ respected in `Service C` and all four
87+
traces will be sampled as new traces in `Service C`. The end result will be five sampled traces.
88+
89+
**Figure 4. Using the `restart` trace continuation strategy**
90+
91+
![Distributed tracing and head based sampling with restart continuation strategy](../images/apm-dt-sampling-continuation-strategy-restart.png)
92+
93+
### OpenTelemetry
4894

4995
Head-based sampling is implemented directly in the APM agents and SDKs.
5096
The sample rate must be propagated between services and the managed intake service in order to produce accurate metrics.
139 KB
Loading
135 KB
Loading
8.44 KB
Loading
13.1 KB
Loading

0 commit comments

Comments
 (0)