Skip to content

Commit 178e177

Browse files
Add troubleshooting for missing transactions (#2427)
As titled. --------- Co-authored-by: Benjamin Ironside Goldstein <[email protected]>
1 parent ce9ad37 commit 178e177

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

troubleshoot/observability/apm-agent-dotnet/apm-net-agent.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,34 @@ Agent.Setup(new AgentComponents(logger: new ApmLoggerAdapter()));
163163
```
164164

165165

166+
## Missing transactions
167+
168+
If you receive trace data for some but not all transactions, you should check the two main variables which control
169+
sampling of transactions.
170+
171+
The first variable is the [transaction sample rate](apm-agent-dotnet://reference/config-core.md#config-transaction-sample-rate). To reduce volume, this configuration option may specify a reduced sampling rate. To sample all transactions, ensure that this is either set to `1`, or not set at all. By default, the agent samples every transaction (every request to your service). ```
172+
173+
The second variable is context propagation. To facilitate distributed tracing, the W3C specification
174+
defines a [trace context](https://www.w3.org/TR/trace-context/), used to transfer a trace across service boundaries.
175+
For web applications, this occurs through the `traceparent` header. Of specific importance for this issue is
176+
a flag defined on that context, the [sampled flag](https://www.w3.org/TR/trace-context/#sampled-flag).
177+
178+
This flag allows a sampling decision made earlier in a distributed trace to continue onto downstream services,
179+
and the .NET APM agent honours this automatically. When a request comes in with the sampling flag
180+
unset (not sampled), the agent will not record a trace in the instrumented service either. This is
181+
by design to avoid collecting incomplete traces.
182+
183+
When all services within a distributed system are managed and instrumented using Elastic APM agents and communication
184+
is internal, the default behaviour is usually correct. If some requests to instrumented applications may come from
185+
external users, then the `traceparent` header cannot be controlled. In these cases, it's often incorrect to allow
186+
an outside party to control what transactions are recorded through the sampled flag.
187+
188+
To control the context propagation behaviour, we have a [trace continuation strategy](apm-agent-dotnet://reference/config-http.md#config-trace-continuation-strategy) option. Choose either `restart` or `restart_external`. `restart` will ignore
189+
the sampling flag on all requests and always include a transaction for the trace. `restart_external` is similar,
190+
however it uses an extra header to detect if the calling service was instrumented by an Elastic APM agent. If so,
191+
it honors the sampling flag; if not (such as for an external request), it forces the trace to be sampled.
192+
193+
166194
## Following error appears in logs: `The singleton APM agent has already been instantiated and can no longer be configured.` [double-agent-initialization-log]
167195

168196
See "[An `InstanceAlreadyCreatedException` exception is thrown](#double-agent-initialization)".

0 commit comments

Comments
 (0)