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
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,37 @@ 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, two main variables control
169
+
sampling of transactions which should be checked.
170
+
171
+
By default, the agent samples every transaction (e.g. a request to your service). To reduce volume,
172
+
the [transaction sample rate](apm-agent-dotnet://reference/config-core.md#config-transaction-sample-rate) configuration
173
+
option may have been configured with a reduced sampling rate. Check that this is set to either 1, or
174
+
not set at all if you plan to sample all transactions.
175
+
176
+
The second variable is context propagation. To facilitate distributed tracing, the W3C specification
177
+
defines a [trace context](https://www.w3.org/TR/trace-context/), used to transfer a trace across service boundaries.
178
+
For web applications, this occurs through the traceparent header. Of specific importance for this issue is
179
+
a flag defined on that context, the [sampled flag](https://www.w3.org/TR/trace-context/#sampled-flag).
180
+
181
+
This flag allows a sampling decision made earlier in a distributed trace to continue onto downstream services,
182
+
and the .NET APM agent honours this automatically. When a request comes in with the sampling flag
183
+
unset (not sampled), the agent will not record a trace in the instrumented service either. This is
184
+
by design as incomplete distributed traces are normally not desired.
185
+
186
+
When all services within a distributed system are managed and instrumented using Elastic APM agents and communication
187
+
is internal, the default behaviour is usually correct. If some requests to instrumented applications may come from
188
+
external users, then the `traceparent` header cannot be controlled. In these cases, it's often incorrect to allow
189
+
an outside party to control what transactions are recorded through the sampled flag.
190
+
191
+
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
192
+
the sampling flag on all requests and always include a transaction for the trace. `restart_external` is similar,
193
+
however, we use an extra header to detect if the calling service was instrumented by an Elastic APM agent. If so,
194
+
we honour the sampling flag; if not (i.e. an external request), we force the trace to be sampled.
195
+
196
+
166
197
## Following error appears in logs: `The singleton APM agent has already been instantiated and can no longer be configured.`[double-agent-initialization-log]
167
198
168
199
See "[An `InstanceAlreadyCreatedException` exception is thrown](#double-agent-initialization)".
0 commit comments