---
title: Send Azure Container Apps Traces with the Managed OpenTelemetry Agent
description: >-
  Export traces from a Datadog SDK or an OpenTelemetry SDK to Datadog through
  the Azure Container Apps managed OpenTelemetry agent.
breadcrumbs: >-
  Docs > Serverless > Azure Container Apps > Send Azure Container Apps Traces
  with the Managed OpenTelemetry Agent
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Send Azure Container Apps Traces with the Managed OpenTelemetry Agent

## Overview{% #overview %}

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

{% alert level="info" %}
OTLP trace export from Datadog SDKs and the Azure Container Apps managed OpenTelemetry agent are in Preview.
{% /alert %}
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry

{% alert level="info" %}
The Azure Container Apps managed OpenTelemetry agent is in Preview.
{% /alert %}
{% /section %}

The Azure Container Apps managed OpenTelemetry agent receives OTLP data from your apps and forwards it to Datadog. Use this setup if you want Azure to manage the collection layer instead of running a Datadog Agent or OpenTelemetry Collector sidecar.

You can send traces to the managed agent with a Datadog SDK or an OpenTelemetry SDK. Select your SDK at the top of this page.

Your app sends traces in OTLP format over gRPC to the managed agent. The managed agent forwards them to Datadog using the Datadog site and API key configured on your Container Apps environment.

Other ways to send traces from Azure Container Apps to Datadog include:

- [`serverless-init`](https://docs.datadoghq.com/serverless/azure_container_apps.md), the Datadog-native option, which collects traces plus enhanced metrics, custom metrics, and logs.
- [Direct OTLP intake](https://docs.datadoghq.com/opentelemetry/setup/otlp_ingest/serverless.md?tab=azure#container-apps), which sends traces from an OpenTelemetry SDK straight to Datadog over HTTP.

## Prerequisites{% #prerequisites %}

- An Azure Container Apps environment. You configure its managed OpenTelemetry agent in the first Setup step.
- A [Datadog API key](https://docs.datadoghq.com/account_management/api-app-keys.md) and your [Datadog site](https://docs.datadoghq.com/getting_started/site.md).

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

- A Java application using the Datadog Java tracer v1.62.0 or later.
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry

- An application instrumented with an OpenTelemetry SDK whose OTLP trace exporter supports gRPC.
{% /section %}

### Language support{% #language-support %}

The managed agent accepts only the gRPC protocol.

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

This page documents Java, the only Datadog SDK that exports OTLP traces over gRPC. Other Datadog SDKs export OTLP traces only over HTTP or do not support OTLP trace export, so they cannot send traces to the managed agent:

| SDK     | Supported OTLP protocols     |
| ------- | ---------------------------- |
| Python  | `http/json`                  |
| Node.js | `http/json`                  |
| Go      | `http/protobuf`              |
| .NET    | `http/json`, `http/protobuf` |
| Ruby    | Not supported                |
| PHP     | Not supported                |

For the latest protocol support, see [Export Traces from Datadog SDKs in OTLP Format](https://docs.datadoghq.com/opentelemetry/instrument/dd_sdks/otlp_trace_export.md).

For other languages, select **OpenTelemetry SDK** at the top of this page, or use [`serverless-init`](https://docs.datadoghq.com/serverless/azure_container_apps.md).
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry

Use any OpenTelemetry SDK whose OTLP trace exporter supports gRPC. For SDKs by language, see the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/).
{% /section %}

## Setup{% #setup %}

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API
Configure Datadog as a destination
Configure the managed agent on your Container Apps environment to send traces to Datadog. You need your Datadog site (<YOUR_DATADOG_SITE>) and API key.

To configure it with the Azure CLI, run:

```
az containerapp env telemetry data-dog set \
  --resource-group <RESOURCE_GROUP> \
  --name <ENVIRONMENT_NAME> \
  --site <DATADOG_SITE> \
  --key <DATADOG_API_KEY> \
  --enable-open-telemetry-traces true
```

For other options, such as Bicep, see [Export OpenTelemetry data to Datadog in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-export-datadog) in the Azure documentation.
Instrument your app with the Datadog Java tracer
Add the Datadog Java tracer to your application image and attach it with the `-javaagent` JVM flag. For instructions, see [Tracing Java applications](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/java.md).
Set the environment variables
Set the following environment variables on your container app. For how to set environment variables, see [Manage environment variables on Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/environment-variables) in the Azure documentation.

| Variable                             | Description                                                                                                       |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `DD_SERVICE`, `DD_ENV`, `DD_VERSION` | Datadog [unified service tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging.md). |
| `DD_TRACE_OTEL_ENABLED`              | Set to `true` to enable OTLP trace export.                                                                        |
| `OTEL_TRACES_EXPORTER`               | Set to `otlp` to export traces in OTLP format.                                                                    |
| `OTEL_EXPORTER_OTLP_PROTOCOL`        | Set to `grpc`. The managed agent accepts only gRPC.                                                               |
| `OTEL_RESOURCE_ATTRIBUTES`           | Set the required resource attributes (see below).                                                                 |

Set `OTEL_RESOURCE_ATTRIBUTES` with the following required attributes:

```
cloud.provider=azure,cloud.platform=azure.container_apps,cloud.resource_id=/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/containerApps/<APP_NAME>
```

To set all of these variables in one command with the Azure CLI, run:

```
az containerapp update \
  --resource-group <RESOURCE_GROUP> \
  --name <APP_NAME> \
  --set-env-vars \
    DD_SERVICE=<SERVICE_NAME> \
    DD_ENV=<ENV> \
    DD_VERSION=<VERSION> \
    DD_TRACE_OTEL_ENABLED=true \
    OTEL_TRACES_EXPORTER=otlp \
    OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
    OTEL_RESOURCE_ATTRIBUTES="cloud.provider=azure,cloud.platform=azure.container_apps,cloud.resource_id=/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/containerApps/<APP_NAME>"
```
Confirm the OTLP endpoint
The Datadog SDK sends traces to the URL in `OTEL_EXPORTER_OTLP_ENDPOINT`. Azure documents this variable as injected automatically (see [Environment variables](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-agents#environment-variables) in the Azure documentation), but it may be missing from your container. If it is missing, the SDK sends traces to its default endpoint on `localhost`, where nothing listens, and traces are dropped without errors.

After you deploy, list the environment variables in your running container:

```
az containerapp exec --resource-group <RESOURCE_GROUP> --name <APP_NAME> --command "printenv"
```

If `OTEL_EXPORTER_OTLP_ENDPOINT` is missing, set it to the managed agent's base URL:

1. Copy the value of `CONTAINERAPP_OTEL_TRACING_GRPC_ENDPOINT` from the output.
1. Remove the trailing `/v1/traces` path. The result looks like `http://<AGENT_HOST>:4317`.
1. Set `OTEL_EXPORTER_OTLP_ENDPOINT` to that value on your container app.

Use the hostname from your own container's variables, not from documentation examples. Set either `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, not both.
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry
Configure Datadog as a destination
Configure the managed agent on your Container Apps environment to send traces to Datadog. You need your Datadog site (<YOUR_DATADOG_SITE>) and API key.

To configure it with the Azure CLI, run:

```
az containerapp env telemetry data-dog set \
  --resource-group <RESOURCE_GROUP> \
  --name <ENVIRONMENT_NAME> \
  --site <DATADOG_SITE> \
  --key <DATADOG_API_KEY> \
  --enable-open-telemetry-traces true
```

For other options, such as Bicep, see [Export OpenTelemetry data to Datadog in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-export-datadog) in the Azure documentation.
Instrument your app with an OpenTelemetry SDK
Add the OpenTelemetry SDK and OTLP trace exporter for your language to your application, and configure the exporter to use gRPC. For instructions, see the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/) for your language.
Set the environment variables
Set the following environment variables on your container app. For how to set environment variables, see [Manage environment variables on Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/environment-variables) in the Azure documentation.

| Variable                      | Description                                                  |
| ----------------------------- | ------------------------------------------------------------ |
| `OTEL_SERVICE_NAME`           | The name of your service. Maps to the Datadog `service` tag. |
| `OTEL_TRACES_EXPORTER`        | Set to `otlp` to export traces in OTLP format.               |
| `OTEL_EXPORTER_OTLP_PROTOCOL` | Set to `grpc`. The managed agent accepts only gRPC.          |
| `OTEL_RESOURCE_ATTRIBUTES`    | Set the required resource attributes (see below).            |

Set `OTEL_RESOURCE_ATTRIBUTES` with the following required attributes. To set the Datadog `env` and `version` tags, also add `deployment.environment.name` and `service.version`. For how OpenTelemetry attributes map to Datadog tags, see [Unified service tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging.md).

```
cloud.provider=azure,cloud.platform=azure.container_apps,cloud.resource_id=/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/containerApps/<APP_NAME>,deployment.environment.name=<ENV>,service.version=<VERSION>
```

To set all of these variables in one command with the Azure CLI, run:

```
az containerapp update \
  --resource-group <RESOURCE_GROUP> \
  --name <APP_NAME> \
  --set-env-vars \
    OTEL_SERVICE_NAME=<SERVICE_NAME> \
    OTEL_TRACES_EXPORTER=otlp \
    OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
    OTEL_RESOURCE_ATTRIBUTES="cloud.provider=azure,cloud.platform=azure.container_apps,cloud.resource_id=/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/containerApps/<APP_NAME>,deployment.environment.name=<ENV>,service.version=<VERSION>"
```
Confirm the OTLP endpoint
The OpenTelemetry SDK sends traces to the URL in `OTEL_EXPORTER_OTLP_ENDPOINT`. Azure documents this variable as injected automatically (see [Environment variables](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-agents#environment-variables) in the Azure documentation), but it may be missing from your container. If it is missing, the SDK sends traces to its default endpoint on `localhost`, where nothing listens, and traces are dropped.

After you deploy, list the environment variables in your running container:

```
az containerapp exec --resource-group <RESOURCE_GROUP> --name <APP_NAME> --command "printenv"
```

If `OTEL_EXPORTER_OTLP_ENDPOINT` is missing, set it to the managed agent's base URL:

1. Copy the value of `CONTAINERAPP_OTEL_TRACING_GRPC_ENDPOINT` from the output.
1. Remove the trailing `/v1/traces` path. The result looks like `http://<AGENT_HOST>:4317`.
1. Set `OTEL_EXPORTER_OTLP_ENDPOINT` to that value on your container app.

Use the hostname from your own container's variables, not from documentation examples. Set either `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, not both.
{% /section %}

## Verify traces in Datadog{% #verify-traces-in-datadog %}

Send requests to your app, wait a few minutes, then open the [Trace Explorer](https://docs.datadoghq.com/tracing/trace_explorer.md) and search for `service:<SERVICE_NAME>`. If no traces appear, see Troubleshooting.

## Troubleshooting{% #troubleshooting %}

If no traces appear in Datadog, check each step from your app to the managed agent:

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

1. **Confirm the tracer is exporting OTLP.** In your container's console logs, find the tracer startup line that contains `TRACER CONFIGURATION`, and confirm that `"otlp_traces_export_enabled": true`. For how to read console logs, see [Log monitoring in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/log-monitoring) in the Azure documentation.

1. **Confirm spans are created.** Set `DD_TRACE_DEBUG=true`, send requests, and look for `Started span` and `Finished span (WRITTEN)` lines in the console logs. If you see these lines but no traces in Datadog, spans are not reaching the managed agent. Remove `DD_TRACE_DEBUG` after you finish.
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry

1. **Confirm the SDK is loaded.** Check your container's console logs for errors from the OpenTelemetry SDK at startup. For how to read console logs, see [Log monitoring in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/log-monitoring) in the Azure documentation.

1. **Confirm spans are created.** Temporarily add a console exporter, for example by setting `OTEL_TRACES_EXPORTER=otlp,console` if your SDK supports multiple exporters. Send requests and look for span output in the console logs. If you see spans but no traces in Datadog, spans are not reaching the managed agent. Remove the console exporter after you finish.
{% /section %}

**Confirm the OTLP endpoint is set.** Check that `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_PROTOCOL=grpc` are present in your running container. If the endpoint is missing, traces are dropped without errors. To check and set it, see the Confirm the OTLP endpoint step in Setup.

**Confirm the Datadog destination.** Verify that the Datadog site and API key are configured on the Container Apps environment (Step 1).

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

### Connection errors to `localhost:8126`{% #connection-errors-to- %}

You may see repeated errors such as `Failed to upload batch to http://localhost:8126/debugger/v1/diagnostics` in your logs. These come from tracer features that expect a local Datadog Agent, which this setup does not use. They do not affect OTLP trace export. To reduce the noise, set `DD_REMOTE_CONFIG_ENABLED=false` and `DD_DYNAMIC_INSTRUMENTATION_ENABLED=false`.
{% /section %}

## Limitations{% #limitations %}

{% section displayed-if="SDK is Datadog API" %}
This section only applies to users who meet the following criteria: SDK is Datadog API

- OTLP trace export from Datadog SDKs supports core APM functionality. Other Datadog features may not be supported, or may require the Datadog Agent. See [Export Traces from Datadog SDKs in OTLP Format](https://docs.datadoghq.com/opentelemetry/instrument/dd_sdks/otlp_trace_export.md).
- The managed agent accepts only the gRPC protocol, which limits the SDKs you can use (see Language support).
{% /section %}

{% section displayed-if="SDK is OpenTelemetry" %}
This section only applies to users who meet the following criteria: SDK is OpenTelemetry

- Some Datadog features are not available for traces from OpenTelemetry SDKs. See [Feature compatibility](https://docs.datadoghq.com/opentelemetry/compatibility.md#feature-compatibility).
- The managed agent accepts only the gRPC protocol. Your SDK's OTLP trace exporter must support gRPC.
{% /section %}

For limitations of the managed OpenTelemetry agent itself, see the [Azure documentation](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-agents).

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Azure Container Apps](https://docs.datadoghq.com/serverless/azure_container_apps.md)
- [Export Traces from Datadog SDKs in OTLP Format](https://docs.datadoghq.com/opentelemetry/instrument/dd_sdks/otlp_trace_export.md)
- [Send Azure Container Apps traces to Datadog with OTLP](https://docs.datadoghq.com/opentelemetry/setup/otlp_ingest/serverless.md?tab=azure#container-apps)
- [Collect and read OpenTelemetry data in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-agents)
- [Export OpenTelemetry data to Datadog in Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps/opentelemetry-export-datadog)
