OpenTelemetry plugin for AWS Message Processing Framework for .NET

July 29, 2025 ยท View on GitHub

nuget downloads

This package is an Instrumentation Library, which instruments the AWS Message Processing Framework for .NET to collect traces about messages that are sent and received.

Configuration

1. Install Packages

Add a reference to AWS.Messaging.Telemetry.OpenTelemetry. In this example, we're going to configure OpenTelemetry on our IServiceCollection, so also add a reference to OpenTelemetry.Extensions.Hosting. This is not required if starting and stopping tracing via CreateTracerProviderBuilder.

You may also add a reference to one or more exporters to visualize your telemetry data.

dotnet add package AWS.Messaging.Telemetry.OpenTelemetry
dotnet add package OpenTelemetry.Extensions.Hosting

2. Enable Instrumentation

In the Startup class add a call to AddOpenTelemetry to configure OpenTelemetry. On the TracerProviderBuilder, call AddAWSMessagingInstrumentation to begin capturing traces for the AWS Message Processing Framework for .NET.

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddAWSMessageBus(builder =>
        {
            builder.AddSQSPoller("https://sqs.us-west-2.amazonaws.com/012345678910/MPF");
            builder.AddMessageHandler<ChatMessageHandler, ChatMessage>("chatMessage");
        });

        services.AddOpenTelemetry()
            .ConfigureResource(resource => resource.AddService("myApplication"))
            .WithTracing(tracing => tracing
                .AddAWSMessagingInstrumentation()
                .AddConsoleExporter());
    }
}

AWS X-Ray Linked Spans Configuration

  1. If you are using OTEL with X-Ray, make sure you configure your OTEL setup to use OTLP for Cloudwatch. This is needed in order to view linked spans in the AWS X-Ray console. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-OTLPSimplesetup.html

Useful Links

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.