---
title: Export MLflow traces to OpenTelemetry
description: Export MLflow traces outbound to an external OpenTelemetry collector such as Datadog, Grafana, or Splunk, or use dual export to send traces to both Databricks MLflow and your existing observability platform.
canonical_url: https://docs.databricks.com/aws/en/mlflow3/genai/tracing/otel-export
---

# Export MLflow traces to OpenTelemetry

MLflow tracing is built on [OpenTelemetry](https://opentelemetry.io/) (OTel). Because every trace MLflow captures is a set of OTel spans, you can export those spans outbound to any OpenTelemetry-compatible observability platform — such as Datadog, Grafana, or Splunk — over the standard OTLP protocol. You can send traces exclusively to an external collector, or use dual export to send them to both Databricks MLflow and your existing observability stack at the same time.

***

## Export MLflow traces to an external OTel collector

MLflow can export traces outbound to any OpenTelemetry-compatible observability platform. Three modes are supported.

### OTel-only export

To send traces exclusively to an external OTel collector (bypassing Databricks MLflow storage), set `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` before starting any trace:

```python
import os
import mlflow

os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = "http://localhost:4317/v1/traces"
os.environ["OTEL_SERVICE_NAME"] = "<your-service-name>"

# Trace is exported ONLY to the OTel collector at http://localhost:4317/v1/traces
with mlflow.start_span(name="foo") as span:
    span.set_inputs({"a": 1})
    span.set_outputs({"b": 2})
```

### Dual export (MLflow + OTel)

To export traces to both Databricks MLflow and an external OTel collector simultaneously, set `MLFLOW_ENABLE_DUAL_EXPORT`:

```python
import os
import mlflow

os.environ["MLFLOW_ENABLE_DUAL_EXPORT"] = "true"
os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = "http://localhost:4317/v1/traces"
os.environ["OTEL_SERVICE_NAME"] = "my-ml-service"

mlflow.set_tracking_uri("databricks")

# Traces are exported to BOTH MLflow and the OTel collector
with mlflow.start_span(name="dual_export_example") as span:
    span.set_inputs({"model": "gpt-4", "prompt": "Hello world"})
    span.set_outputs({"response": "Generated response"})
```

### Metrics export

MLflow exports OTel metrics when a metrics endpoint is configured. For the complete list of exported metrics, see the [MLflow documentation](https://mlflow.org/docs/latest/genai/tracing/prod-tracing/#exported-metrics).

```python
import os

os.environ["OTEL_METRICS_EXPORTER"] = "otlp"
os.environ["OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"] = "http://localhost:4317"
# Optional: configure export interval in milliseconds
os.environ["OTEL_METRIC_EXPORT_INTERVAL"] = "60000"
```

### Supported platforms

MLflow uses the standard OTLP exporter and supports [all OTLP exporter configurations](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/). The following platforms have published OTel setup guides:

| Platform                                              | OpenTelemetry documentation                                                                                                                      |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Datadog](https://www.datadoghq.com/)                 | [OpenTelemetry Guide](https://docs.datadoghq.com/opentelemetry/)                                                                                 |
| [New Relic](https://newrelic.com/)                    | [OpenTelemetry APM Monitoring](https://docs.newrelic.com/docs/opentelemetry/get-started/apm-monitoring/opentelemetry-apm-intro/#review-settings) |
| [SigNoz](https://signoz.io/)                          | [OpenTelemetry Python Instrumentation](https://signoz.io/docs/instrumentation/opentelemetry-python/)                                             |
| [Splunk](https://www.splunk.com/)                     | [Get Data In](https://docs.splunk.com/observability/en/gdi/get-data-in/get-data-in.html)                                                         |
| [Grafana](https://grafana.com/)                       | [Send Data via OTLP](https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/)                                                      |
| [ServiceNow (Lightstep)](https://www.servicenow.com/) | [Collector Documentation](https://docs.lightstep.com/docs/collector-home-page)                                                                   |

To use HTTP protocol instead of the default gRPC or to set custom headers:

```bash
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://localhost:4317/v1/traces"
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="api_key=12345"
```

***

## Additional resources

* [Export Langfuse traces to Databricks](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/integrations/langfuse.md) — Route Langfuse traces to Databricks over the OTLP endpoint.
* [Custom OpenTelemetry instrumentation](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/manual-tracing.md#custom-opentelemetry-instrumentation) — Set OTel span attributes for a custom-instrumented agent and search ingested traces.
* [Store OpenTelemetry traces in Unity Catalog](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/trace-unity-catalog.md) — Store and manage traces in Unity Catalog tables.
* [View traces in the Databricks MLflow UI](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/observe-with-traces/ui-traces.md) — Search and filter traces in the MLflow UI.
* [Observe and find issues](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/observe-with-traces/index.md) — Query trace data at scale using Databricks SQL.
* [Programmatic access to traces](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/observe-with-traces/query-via-sdk.md) — Search and filter traces programmatically with the MLflow SDK.
* [Enrich traces: tags, context, and feedback](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/enrich-traces.md) — Attach searchable tags to traces.

**Next step:** [Observe and find issues](https://docs.databricks.com/aws/en/mlflow3/genai/tracing/observe-with-traces/index.md)
