Log Analytics
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

missing logs in some spans

irivas1
Visitor

Hi,

I have some traces where some spans have logs, but others don't. This issue occurs primarily in .NET applications.
I have the log enrichment options enabled in the OneAgent features:

oneagent features.png

I'll include an example to make it clearer; in this trace, you can see how logs appear in the span

span with log.png

However, they do not appear in this span

 

 

span without log.png

 

but I have verified that there are logs for this call, which in theory should be correlated.

I still can't get all spans to have associated logs. Could you help me figure out what's causing this?

 

Thanks and regards

1 REPLY 1

t_pawlak
Leader

Hi,

Based on your description and screenshots, your OneAgent log enrichment configuration looks correct, since some spans already have correlated logs.

In this case, the issue is usually not configuration-related, but rather caused by missing context propagation (trace/span) in the application.

OneAgent is working correctly and the issue is caused by incomplete context propagation in the .NET application

Dynatrace can only correlate logs with spans when the log is created within the same execution context (thread/request), or the log contains trace_id and span_id.

If logs are generated:

  • in async/await,
  • inside Task.Run,
  • in background tasks or event handlers,
  • or outside the request lifecycle,

the context can be lost. In such cases, both the span and log exist, but they are not correlated.

That’s why you see logs only for some spans.

I think you should check:

  • whether logs are created in the same execution context as the span,
  • whether your logger preserves context (e.g., Activity.Current in .NET),
  • whether logs contain trace_id / span_id (especially for custom ingestion).

Possible solutions:

  • ensure proper context propagation in async flows (Activity / OpenTelemetry),
  • avoid losing context in Task.Run,
  • optionally enrich logs manually with trace_id and span_id (e.g., Serilog / NLog).

 

Featured Posts