OpenTelemetry LLM tracing records every step of an LLM application or agent (model calls, retrieval, tool calls) as OpenTelemetry spans, so the trace can move between tools over the vendor-neutral OTLP protocol. MLflow supports it in both directions: the MLflow Server ingests OTLP traces from any OpenTelemetry client, and MLflow Tracing exports traces and metrics to any OTLP-compatible backend.
MLflow Tracing is built on the OpenTelemetry SDK and reads and writes the OpenTelemetry GenAI semantic conventions, so your trace data is not tied to one vendor's format. You can instrument with the MLflow SDK, with plain OpenTelemetry libraries in any language, or with both in the same application.

A trace in the MLflow UI: nested spans for model and tool calls, with latency, token usage, and cost on each span (MLflow demo data)
Quick Navigation:
OpenTelemetry is a CNCF-backed project that defines vendor-neutral APIs, SDKs, and a wire protocol (OTLP) for telemetry. A trace is a tree of spans, where each span is one timed operation with attributes. For an LLM application, a span might be a call to a model, a vector search, or a tool invocation, nested under the span for the request or agent run that triggered it.
What makes LLM tracing different from ordinary service tracing is the content of the spans: prompts and responses, the model and provider, token counts, and the structure of an agent's reasoning steps. The OpenTelemetry GenAI semantic conventions standardize the attribute names for this data so that a trace produced by one tool can be understood by another.
Using OpenTelemetry for LLM tracing means you can instrument once and choose where the data goes: an AI-focused platform for debugging and evaluation, an existing observability stack for operations, or both. For the broader picture of tracing agents and LLM applications, see LLM tracing with MLflow.
| Direction | What it does | Use it when |
|---|---|---|
| Instrument with the MLflow SDK | MLflow Tracing, built on the OpenTelemetry SDK, adds one-line auto-tracing for popular LLM and agent frameworks and enriches spans with prompts, token usage, and model names. | Your application is in Python or TypeScript/JavaScript and you want the fastest path to useful traces. |
| Ingest OTLP into MLflow | The MLflow Server accepts OTLP traces over HTTP at /v1/traces. | You use OpenTelemetry instrumentation directly, or write in Java, Go, Rust, or another language. |
| Export from MLflow over OTLP | MLflow sends traces and span-duration metrics to any OTLP endpoint, optionally at the same time as MLflow. | You already run Datadog, Grafana, Jaeger, or another OpenTelemetry-compatible backend. |
The MLflow Server exposes an OTLP endpoint at /v1/traces. Start the server with a SQL backend store, then point any OpenTelemetry exporter at it and tell MLflow which experiment should hold the traces with the x-mlflow-experiment-id header. Trace ingestion is available in MLflow 3.6.0 and above.
# Start MLflow (SQLite backend by default)mlflow server# In your application's environmentexport OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:5000/v1/tracesexport OTEL_EXPORTER_OTLP_TRACES_HEADERS=x-mlflow-experiment-id=123
Any OpenTelemetry SDK reads these standard variables, so the same setup works for a FastAPI app instrumented with OpenTelemetry, a Java service using Spring AI, or a Go worker. If your applications send traces to an OpenTelemetry Collector, add an otlphttp exporter that targets MLflow:
receivers:otlp:protocols:grpc:endpoint: 0.0.0.0:4317http:endpoint: 0.0.0.0:4318exporters:otlphttp:endpoint: http://localhost:5000headers:x-mlflow-experiment-id: "123"service:pipelines:traces:receivers: [otlp]processors: [batch]exporters: [otlphttp]
A few details worth knowing:
gzip and deflate compressed payloads. Clients enable it with OTEL_EXPORTER_OTLP_TRACES_COMPRESSION on their exporter.X-MLFLOW-WORKSPACE header to override the default workspace.See Collect OpenTelemetry Traces into MLflow for the full guide.
Traces created by MLflow follow the OpenTelemetry trace spec, so you can send them to any platform that accepts OTLP. Set the endpoint before starting a trace and install the exporter package. MLflow's OTLP exporter uses gRPC unless you set the protocol, so the example below selects http/protobuf to match an HTTP endpoint:
# pip install opentelemetry-exporter-otlpimport osimport mlflowos.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = "http://localhost:4318/v1/traces"os.environ["OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"] = "http/protobuf"os.environ["OTEL_SERVICE_NAME"] = "my-llm-service" # optional, groups traceswith mlflow.start_span(name="foo") as span:span.set_inputs({"a": 1})span.set_outputs({"b": 2})
By default, once an OTLP endpoint is configured MLflow sends traces to that endpoint only. Set MLFLOW_TRACE_ENABLE_OTLP_DUAL_EXPORT=true to dual export: traces go to both the MLflow Tracking Server and your OpenTelemetry backend.
import osimport mlflowos.environ["MLFLOW_TRACE_ENABLE_OTLP_DUAL_EXPORT"] = "true"os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = "http://localhost:4318/v1/traces"os.environ["OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"] = "http/protobuf"mlflow.set_tracking_uri("http://localhost:5000")mlflow.set_experiment("my-experiment")with mlflow.start_span(name="foo") as span:span.set_inputs({"a": 1})span.set_outputs({"b": 2})
All standard OpenTelemetry exporter settings apply, such as OTEL_EXPORTER_OTLP_TRACES_PROTOCOL and OTEL_EXPORTER_OTLP_TRACES_HEADERS for API keys. The MLflow docs include setup links for Datadog, New Relic, SigNoz, Splunk, Grafana, Jaeger, Dynatrace, and other OpenTelemetry-compatible platforms.
Metrics. When an OTLP metrics endpoint is configured (OTEL_EXPORTER_OTLP_METRICS_ENDPOINT), MLflow also exports a mlflow.trace.span.duration histogram in milliseconds. It carries attributes such as the span type, span status, whether the span is the root, and the experiment ID, so you can chart latency and error rates in Prometheus, Grafana, or whichever metrics system you run. See Export MLflow Traces/Metrics via OTLP.
The OpenTelemetry GenAI semantic conventions define a shared schema for AI telemetry. MLflow supports them on both sides:
gen_ai.* attributes and shows them with proper span types, token counts, model information, and structured inputs and outputs. The MLflow docs list integrations that produce them, including Google ADK, LiveKit Agents, and Spring AI.mlflow.* attributes. Set MLFLOW_ENABLE_OTEL_GENAI_SEMCONV=true (MLflow 3.11 and above) to translate them to gen_ai.* at export time. Message conversion is supported for OpenAI (Chat Completions and Responses), Anthropic, Google Gemini, and Amazon Bedrock.| MLflow attribute | GenAI semantic convention attribute |
|---|---|
mlflow.spanType | gen_ai.operation.name |
mlflow.llm.model | gen_ai.request.model |
mlflow.llm.provider | gen_ai.provider.name |
mlflow.chat.tokenUsage | gen_ai.usage.input_tokens / gen_ai.usage.output_tokens |
mlflow.spanInputs | gen_ai.input.messages |
mlflow.spanOutputs | gen_ai.output.messages |
The full mapping is in the attribute mapping reference.
Because MLflow Tracing is built on the OpenTelemetry SDK, you can keep the OpenTelemetry instrumentation you already have for HTTP frameworks, databases, and network calls, and add MLflow's AI-specific tracing on top. Set MLFLOW_USE_DEFAULT_TRACER_PROVIDER to false so MLflow uses the global tracer provider, then call mlflow.tracing.set_destination after your provider is configured. MLflow spans nest under the OpenTelemetry spans in a single trace.
import osimport mlflowfrom mlflow.entities.trace_location import MlflowExperimentLocationfrom opentelemetry import trace as otel_tracefrom opentelemetry.sdk.trace import TracerProvider# Use the OpenTelemetry tracer provider instead of MLflow's default oneos.environ["MLFLOW_USE_DEFAULT_TRACER_PROVIDER"] = "false"mlflow.set_tracking_uri("http://localhost:5000")experiment_id = mlflow.set_experiment("my_experiment").experiment_idotel_trace.set_tracer_provider(TracerProvider())# Must be called after the tracer provider is configuredmlflow.tracing.set_destination(MlflowExperimentLocation(experiment_id))otel_tracer = otel_trace.get_tracer("my_app")with otel_tracer.start_as_current_span("http_request") as external_span:external_span.set_attribute("http.method", "GET")# This MLflow span is nested under the OpenTelemetry spanwith mlflow.start_span("model_prediction") as mlflow_span:mlflow_span.set_inputs({"query": "test"})mlflow_span.set_outputs({"result": "success"})
The same approach lets MLflow's one-line auto-tracing, for example mlflow.openai.autolog(), share a trace with spans from OpenTelemetry's FastAPI instrumentation. See Tracing with OpenTelemetry for a full FastAPI example.
Any OTLP backend can store spans. Debugging an LLM application usually needs more than storage, and this is where MLflow focuses:
If you only need generic service monitoring, an OpenTelemetry backend alone may be enough. You can also run both: OTLP for the operations view and MLflow for debugging and improving the AI behavior.
pip install mlflow, then mlflow server.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT and the x-mlflow-experiment-id header in any OpenTelemetry application.MLFLOW_TRACE_ENABLE_OTLP_DUAL_EXPORT=true to also send traces to your existing OpenTelemetry backend.MLflow is an open-source AI engineering platform for agents, LLMs, and ML models, backed by the Linux Foundation and licensed under Apache 2.0, MLflow provides OpenTelemetry-compatible tracing with no vendor lock-in. Read the tracing docs →