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

Dynatrace not properly representing parent-child Activity relationships


I'm trying to work on adding some additional metadata to our Dynatrace distributed traces in our .NET 6 applications. Specifically, I'm trying to accomplish this using the System.Diagnostics.Activity and ActivitySource types natively within the .NET framework. The spans are mostly picked up by the OneAgent that we already use but there are two primary issues I'm seeing.

  1. Parent-child relationships aren't properly preserved and displayed in Dynatrace after I start a new activity using the activitySource.StartActivity() method. I've verified that the default behavior within .NET is working as expected and setting the parent context, and an OpenTelemetry exporter properly displays that parent-child relationship in the flame graph, but Dynatrace doesn't seem to observe it.
    1. This seems to be an issue similar to what is discussed in this thread: Solved: Re: Question: OpenTelemetry all Spans have informational message: "initial value not set" - ... which says that as of 02/2022 Dynatrace didn't really have proper support for this for all language's native tracing. Is that still the case as of 09/29/2023?
  2. I'm noticing that activities created when executing inside of a Parallel.ForEachAsync or a Task.Run statement don't show up in Dynatrace (sample code below). Similar to the above, the activities are created as expected, other tools like OpenTelemetry exports show the tasks and report them correctly, but the Dynatrace OneAgent either isn't collecting them or the Dynatrace interface isn't showing them. Is there some kind of setting or activity listener that needs to be configured for Dynatrace to collect these?


The following code is adapted from my team's application to provide an example of what we're doing:

private readonly ActivitySource _trace; // initialized in constructor

public async Task DoWork(IEnumerable<int> items)
using var doWorkActivity = _trace.StartActivity("DoWork root"); // this shows up in Dynatrace
using var childActivity = _trace.StartActivity("DoWork child"); // this also shows up in Dynatrace, but not as a child of doWork

await Parallel.ForEachAsync(items, async (item, cancellationToken) =>
using var parallelActivity = _trace.StartActivity("DoWork parallel method"); // not in Dynatrace at all
await Task.Run(() =>
using var taskActivity = _trace.StartActivity("DoWork Task.Run"); // Not in dynatrace at all
// business logic