Skip to content

Traces details view bugs related to inconsistent nested activity ordering and collapse/expand not working #8731

@PFAR

Description

@PFAR

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In Aspire 9.2 the Traces details view, child spans within child spans are ordered chronologically reversed:

Image

Also the parent span's collapse/expand chevron is not working anymore.

Expected Behavior

Any child spans within any parent span (not just the root span) are ordered chronologically by start time, collapse/expand chevron at parent span level works as expected.

Steps To Reproduce

Create a new .NET Aspire Starter App

Adapt app.MapGet("/weatherforecast":

app.MapGet("/weatherforecast", async () =>
{
    var forecast = Enumerable.Range(1, 5).Select(index =>
        new WeatherForecast
        (
            DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
            Random.Shared.Next(-20, 55),
            summaries[Random.Shared.Next(summaries.Length)]
        ))
        .ToArray();
    ActivitySource source = new("Services.Api", "1.0.0");
    using Activity activity = source.StartActivity("ValidateAndUpdateCacheService.ExecuteAsync");
    await Task.Delay(100);
    using Activity innerActivity = source.StartActivity("ValidateAndUpdateCacheService.activeUser", ActivityKind.Internal, parentContext: activity.Context);
    await Task.Delay(100);
    using (Activity activity1 = source.StartActivity("Perform1", ActivityKind.Internal, parentContext: innerActivity.Context))
    {
        await Task.Delay(10);
    }
    using (Activity activity2 = source.StartActivity("Perform2", ActivityKind.Internal, parentContext: innerActivity.Context))
    {
        await Task.Delay(20);
    }
    using (Activity activity3 = source.StartActivity("Perform3", ActivityKind.Internal, parentContext: innerActivity.Context))
    {
        await Task.Delay(30);
    }
    using Activity innerActivity2 = source.StartActivity("ValidateAndUpdateCacheService.activeUser", ActivityKind.Internal, parentContext: activity.Context);
    await Task.Delay(100);
    using (Activity activity21 = source.StartActivity("Perform1", ActivityKind.Internal, parentContext: innerActivity2.Context))
    {
        await Task.Delay(30);
    }
    using (Activity activity22 = source.StartActivity("Perform2", ActivityKind.Internal, parentContext: innerActivity2.Context))
    {
        await Task.Delay(20);
    }
    using (Activity activity23 = source.StartActivity("Perform3", ActivityKind.Internal, parentContext: innerActivity2.Context))
    {
        await Task.Delay(10);
    }
    return forecast;
})
.WithName("GetWeatherForecast");

Adapt .WithTracing(tracing =>

            .WithTracing(tracing =>
            {
                tracing.AddSource(builder.Environment.ApplicationName)
                    .AddAspNetCoreInstrumentation(tracing =>
                        // Exclude health check requests from tracing
                        tracing.Filter = context =>
                            !context.Request.Path.StartsWithSegments(HealthEndpointPath)
                            && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
                    )
                    // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
                    //.AddGrpcClientInstrumentation()
                    .AddHttpClientInstrumentation()
                    .AddSource("Services.Api");
            });

Observe the reverse chronological order of the child activities within non-root activities within the Traces details view

Also try to collapse and expand spans within the Traces details view

Exceptions (if any)

No response

.NET Version info

dotnet 8

Anything else?

aspire 9.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions