For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/opentelemetry/setup/otlp_ingest/serverless.md. A documentation index is available at /llms.txt.

Overview

Send traces from serverless workloads directly to Datadog over HTTP/protobuf, without requiring a Datadog Agent or OpenTelemetry Collector. If your platform appears in the Managed platforms table, use its dedicated endpoint instead.

Serverless workloads can also send logs and metrics through the general OTLP logs and OTLP metrics intake endpoints. The resource attributes on this page apply to all signals your application exports.

Supported platforms:

  • AWS: Lambda, ECS Fargate
  • Azure: Container Apps, Web Apps (App Service), Azure Functions
  • GCP: Cloud Run, Cloud Run Functions, GKE Autopilot
Use direct ingest when running a Collector is impractical (for example, Lambda). If you can run a Collector, see OpenTelemetry Collector for metadata enrichment, normalization, and centralized sampling.

Prerequisites

The following configuration applies to all platforms.

Protocol: http/protobuf or http/json. grpc is not supported.

Required headers:

  • dd-api-key: Your Datadog API key.
  • dd-otlp-source: Set to serverless.
  • compute_stats: Set to true. Required for trace metrics.

Service name: Set OTEL_SERVICE_NAME to identify your service. Without it, traces appear as unknown_service.

Resource attributes: Set platform-specific attributes with OTEL_RESOURCE_ATTRIBUTES. See each cloud provider tab below for required and optional attributes.

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=""
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-service"

Setup

Based on your Datadog site, which is : Replace ${YOUR_ENDPOINT} with in the following examples.

Select your cloud provider for platform-specific resource attribute configuration:

Lambda

The AWS Distro for OpenTelemetry (ADOT) Lambda layer provides automatic instrumentation and resource detection for Lambda functions.

Add the ADOT layer to your Lambda function and configure the following environment variables:

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-lambda-function"

The ADOT layer handles resource attribute detection automatically. If you are not using ADOT, set resource attributes manually. cloud.provider is required. Set faas.id (a parseable Lambda ARN) for full platform identification; if faas.id is not available, set cloud.platform=aws_lambda instead:

export OTEL_RESOURCE_ATTRIBUTES="cloud.provider=aws,faas.id=arn:aws:lambda:us-east-1:123456789012:function:my-function"
AttributeRequiredDescription
cloud.providerYesSet to aws
faas.idRecommendedLambda function ARN (preferred for platform identification)
cloud.platformConditionalSet to aws_lambda if faas.id is not set
cloud.regionNoAWS region
faas.nameNoFunction name
faas.versionNoFunction version
faas.instanceNoInstance identifier
faas.max_memoryNoMax memory configured (bytes)
aws.log.group.namesNoCloudWatch log group names (enables trace-log correlation)
aws.log.stream.namesNoCloudWatch log stream names

ECS Fargate

ECS Fargate identification is driven by the task ARN and launch type, not by cloud.provider or cloud.platform. Configure the OpenTelemetry SDK to export traces directly from your ECS task:

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-ecs-service"
export OTEL_RESOURCE_ATTRIBUTES="aws.ecs.task.arn=arn:aws:ecs:us-east-1:123456789012:task/my-cluster/1234567890abcdef,aws.ecs.launchtype=fargate"
AttributeRequiredDescription
aws.ecs.task.arnYesECS task ARN
aws.ecs.launchtypeYesSet to fargate (case-insensitive)
cloud.providerNoDefaults to aws
cloud.platformNoDefaults to aws_ecs
cloud.regionNoAWS region
cloud.availability_zoneNoAvailability zone
aws.ecs.cluster.arnNoCluster ARN
aws.ecs.task.familyNoTask definition family
aws.ecs.task.idNoTask ID
aws.ecs.task.revisionNoTask definition revision
aws.log.group.namesNoCloudWatch log group names (enables trace-log correlation)
aws.log.stream.namesNoCloudWatch log stream names
The OpenTelemetry Collector's Azure resource detection processor only supports VMs. SDK-level Azure resource detectors support some platforms (Web Apps, Functions), but coverage varies by language SDK. Set cloud.provider, cloud.platform, and cloud.resource_id manually as the reliable path for all Azure serverless platforms.

Container Apps

Azure resource detector support for Container Apps varies by language SDK. Set resource attributes manually:

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-container-app"
export OTEL_RESOURCE_ATTRIBUTES="cloud.provider=azure,cloud.platform=azure.container_apps,cloud.resource_id=/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{appName}"

Web Apps (App Service)

Use the Azure resource detector SDK package (coverage varies by language SDK) or set OTEL_RESOURCE_ATTRIBUTES manually:

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-web-app"
export OTEL_RESOURCE_ATTRIBUTES="cloud.provider=azure,cloud.platform=azure.app_service,cloud.resource_id=/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{appName}"

Azure Functions

Use the Azure resource detector SDK package (coverage varies by language SDK) or set OTEL_RESOURCE_ATTRIBUTES manually:

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-azure-function"
export OTEL_RESOURCE_ATTRIBUTES="cloud.provider=azure,cloud.platform=azure.functions,cloud.resource_id=/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{functionAppName}"

Resource attributes reference

Platformcloud.providercloud.platformcloud.resource_id
Container Appsazureazure.container_apps/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{appName}
Web Appsazureazure.app_service/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{appName}
Azure Functionsazureazure.functions/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{functionAppName}

GCP resource detection works automatically with the GCP Resource Detector SDK package. Add it to your application dependencies to populate resource attributes without manual configuration.

Cloud Run and Cloud Run Functions

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-cloud-run-service"

The GCP Resource Detector SDK automatically populates: cloud.account.id, cloud.platform, cloud.provider, cloud.region, faas.id, faas.instance, faas.name, faas.version.

GKE Autopilot

export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="${YOUR_ENDPOINT}"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="dd-api-key=${DD_API_KEY},dd-otlp-source=serverless,compute_stats=true"
export OTEL_SERVICE_NAME="my-gke-service"

The GCP Resource Detector SDK automatically populates: cloud.account.id, cloud.platform, cloud.provider, cloud.region, host.id, k8s.cluster.name.

Resource attributes reference

PlatformAttributes populated by GCP Resource Detector
Cloud Run / Cloud Run Functionscloud.account.id, cloud.platform, cloud.provider, cloud.region, faas.id, faas.instance, faas.name, faas.version
GKE Autopilotcloud.account.id, cloud.platform, cloud.provider, cloud.region, host.id, k8s.cluster.name

Further reading