Skip to content

Using X-Ray UDP Exporter with TracingProvider's resource #291

@daniel-ferguson

Description

@daniel-ferguson

I'd like to be able to use the X-Ray UDP Exporter on AWS lambda, and have traces emitted with rich resource info inferred from the lambda environment (e.g. lambda ARN, memory & CPU available).

I'm struggling to get this working and I suspect it could be due to how the exporter works with Resources. When constructing it, it seems necessary to pass in a fully-built Resource, and I'm not sure how to build a resource that will have all the lambda properties I'm interested in having recorded on my traces. Here's the TracerProviderBuilder setup as shown in the README for this project:

var tracerProvider = Sdk.CreateTracerProviderBuilder()
    // ...
    .AddProcessor(
        new SimpleActivityExportProcessor(
            // Add the X-Ray UDP Exporter
            new XrayUdpExporter(resourceBuilder.Build())
        )
    )

This contrasts with the way I'd add a console or OLTP exporter:

var tracerProvider = Sdk.CreateTracerProviderBuilder()
  .AddOtlpExporter()

I've had a go at reading how AddOtlpExporter works, and it seems to fetch the Resource from its parent provider at runtime: https://github.com/open-telemetry/opentelemetry-dotnet/blob/5f5b6bce4087ef5e76539ed44e93efb53107202d/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs#L63

I'd hope for something similar from XrayUdpExporter. I'm not too familiar with the ecosystem here, so if I'm missing something really obvious about how I can use XrayUdpExporter with the auto-configured resource that .AddAWSLambdaConfigurations attaches to the TracerProvider please let me know.

What else have I tried?

I've also tried building a resource that has all the data I'm interested in - just as AddAWSLambdaConfigurations does (https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/2642fc886e9220f7ccc113f16da82d4813f1fff8/src/OpenTelemetry.Instrumentation.AWSLambda/TracerProviderBuilderExtensions.cs#L46). Unfortunately AWSLambdaResourceDetector is private. If and when open-telemetry/opentelemetry-dotnet-contrib#3411 gets merged and released I might be able work around this issue.


I'm not an expert when it comes to the OpenTelemetry ecosystem in general, nor the dotnet side of it, so here are some assumptions I'm making:

  • Resources represent a thing that traces relate to (a piece of infrastructure, an AWS lambda function, etc.)
  • resource detectors can be registered with a ResourceBuilder, and describe a process for populating information on that resource
  • resource information gets recorded with traces, when those traces are emitted
  • the fact that I'm using a very plain Resource, rather than the one built by calling .AddAWSLambdaConfigurations is the cause of the traces my system records being
  • XrayUdpExporter is fine to use (I'm really hoping this is the case, since at least at first glance it looks like a really good workaround for the 400ms, startup latencies we're seeing when we try to run the OTel collector as a lambda layer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions