You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: troubleshoot/observability/apm-agent-dotnet/apm-net-agent.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,34 @@ Agent.Setup(new AgentComponents(logger: new ApmLoggerAdapter()));
163
163
```
164
164
165
165
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
+
166
194
## Following error appears in logs: `The singleton APM agent has already been instantiated and can no longer be configured.`[double-agent-initialization-log]
167
195
168
196
See "[An `InstanceAlreadyCreatedException` exception is thrown](#double-agent-initialization)".
0 commit comments