open-telemetry / opentelemetry-dotnet-contrib

This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
https://opentelemetry.io
Apache License 2.0
421 stars 251 forks source link

AWS X-Ray traces without span info #1930

Open jphjsoares opened 3 days ago

jphjsoares commented 3 days ago

Component

OpenTelemetry.Extensions.AWS

Package Version

Package Name Version
OpenTelemetry 1.9.0
OpenTelemetry.Contrib.Extensions.AWSXRay 1.2.0
OpenTelemetry.Instrumentation.AspNetCore 1.8.1

Runtime Version

net8.0

Description

I currently have an application that is collecting metrics and traces using Open Telemetry. Locally, I have an Aspire board that shows me the correct traces with the correct span info. I'm trying to see the span info of my traces on AWS.

Steps to Reproduce

This is a snippet of the code I'm using for this example:

(...)
var builder = WebApplication.CreateBuilder(args);
ActivitySource activitySource = new("OTEL");
builder.Services.AddOpenTelemetry()
        .ConfigureResource(resource => resource
            .AddService(
                serviceName: builder.Environment.ApplicationName,
                serviceVersion: appVersion)
            .AddDetector(new ContainerResourceDetector()))
        .WithMetrics(metrics => metrics
            .AddAspNetCoreInstrumentation()
            .AddOtlpExporter()
        .WithTracing(tracing => tracing
            .AddXRayTraceId()
            .AddAWSInstrumentation()
            .AddAspNetCoreInstrumentation()
            .AddSource("OTEL")
            .AddOtlpExporter()
            .AddConsoleExporter());

Sdk.SetDefaultTextMapPropagator(new AWSXRayPropagator());

(...)

app.MapGet("/", (HttpContext context) =>
{
  using var slow = activitySource.StartActivity("Slow span", ActivityKind.Server);
  slow?.SetTag("type", "slow");
  Thread.Sleep(500);

  context.Response.WriteAsync($"Hello World!");

  using var fast = activitySource.StartActivity("Fast span", ActivityKind.Server);
  fast?.SetTag("type", "fast");
  Thread.Sleep(100);
});

Expected Result

I was expecting something similar to what my aspire board is showing, but on AWS side:

image (Note that the delays here were different from the following evidence)

As seen above, the aspire board is showing me the GET /, Fastttt and the Slowwww info.

Actual Result

When testing it in AWS, even though the traces are received and so is the metadata, there is no span info displayed on the waterfall chart. Not even the response code is showing:

image

image

And a snippet of the corresponding metadata:

{
  "default": {
    (...)
    "url.scheme": "http",
    "otel.resource.service.name": "xxxx",
    "otel.resource.telemetry.sdk.version": "1.9.0",
    "url.path": "/",
    "http.request.method": "GET",
    "http.route": "/",
    "http.response.status_code": 200,
    "otel.resource.telemetry.sdk.language": "dotnet"
  }
}

Additional Context

No response