Trace AWS Lambda .NET Core functions with OpenTelemetry .NET

New version available

While you can use the vanilla OpenTelemetry capabilties to instrument your AWS Lambda functions for .NET as described within this tutorial, we recommend to follow our up-leveled version to
trace AWS Lambda .NET functions, which heavily reduces instrumentation effort and gives deeper and better insights into your function invocations.

In Feb 2021, AWS announced Support for AWS Distro for OpenTelemetry .NET Tracing. For general information about AWS Distro for OpenTelemetry, see the AWS Distro for OpenTelemetry page.

For tracing AWS Lambda for other languages such as Java, Node.JS, and Python using the Dynatrace AWS Lambda Layer, see Deploy OneAgent as Lambda extension.

Prerequisites

The following prerequisites and limitations apply:

  • Dynatrace version 1.222+
  • W3C Trace Context is enabled
    1. Go to Settings > Preferences > OneAgent features.
    2. Turn on Send W3C Trace Context HTTP headers.

The OpenTelemetry Protocol (OTLP) exporters for .NET currently support gRPC and HTTP 1.1 with binary Protocol Buffers (Protobuf) payload transports. Supported corresponding protocol values are grpc and http/protobuf. Configuration options can be set either via environment variables or explicitly in code.

Instrument AWS Lambda .NET Core functions

Dynatrace uses OpenTelemetry trace ingest to provide end-to-end visibility to your AWS Lambda .NET Core functions.

To instrument your AWS Lambda .NET Core functions

Step 1 Set up export

Step 2 Add dependencies

Add the following dependencies via NuGet to your project:

OpenTelemetry.Exporter.OpenTelemetryProtocol

If you are using the AWS SDK to interact with other AWS services, you can add auto-instrumentation using the ADOT SDK for .NET

OpenTelemetry.Contrib.Instrumentation.AWS

OpenTelemetry also provides other auto-instrumentation libraries available as NuGet packages

Step 3 Add OpenTelemetry Tracer