Automatic tracing and integrations
One call — mlflow.<framework>.autolog() — enables tracing for any of 30+ supported frameworks and LLM providers. It patches the library at import time so every LLM invocation, tool call, and agent step is captured as a span with no additional instrumentation.
Enable automatic tracing
note
On serverless compute clusters, autologging is not enabled by default. You must call mlflow.<library>.autolog() explicitly for each integration you want to trace.
Install
Python
%pip install --upgrade "mlflow[databricks]>=3.1.0" "openai>=1.0.0"
# Also install the SDKs for any other frameworks you want to trace
dbutils.library.restartPython()
Set credentials
- Databricks notebook
- External environment
Python
import os
os.environ["OPENAI_API_KEY"] = "your-api-key"
# Add other provider keys as needed:
# os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
Bash
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="your-databricks-token"
# Add provider keys for your chosen LLM
Quickstart examples
Choose your framework to see a minimal working example. Each tab links to the full per-framework guide.
- OpenAI
- LangChain
- LangGraph
- Anthropic
- Databricks FMAPI
- DSPy
- Bedrock
- AutoGen
Python
import mlflow
import openai
mlflow.openai.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/openai-tracing-demo")
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What is the capital of France?"}],
)
# Trace appears in the MLflow UI automatically
Python
import mlflow
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
mlflow.langchain.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/langchain-tracing-demo")
chain = (
ChatPromptTemplate.from_template("Tell me a joke about {topic}.")
| ChatOpenAI(model="gpt-4o-mini", temperature=0.7)
| StrOutputParser()
)
chain.invoke({"topic": "artificial intelligence"})
Python
import mlflow
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
mlflow.langchain.autolog() # LangGraph uses LangChain's autolog
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/langgraph-tracing-demo")
@tool
def get_weather(city: str):
"""Get weather for a city."""
return f"It might be cloudy in {city}"
graph = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), [get_weather])
graph.invoke({"messages": [("user", "What is the weather in SF?")]})
Python
import mlflow
import anthropic
import os
mlflow.anthropic.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/anthropic-tracing-demo")
client = anthropic.Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
Python
import mlflow
import os
from openai import OpenAI
# Databricks Foundation Model APIs use the OpenAI client
mlflow.openai.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/databricks-fmapi-tracing")
client = OpenAI(
api_key=os.environ.get("DATABRICKS_TOKEN"),
base_url=f"{os.environ.get('DATABRICKS_HOST')}/serving-endpoints",
)
response = client.chat.completions.create(
model="databricks-llama-4-maverick",
messages=[{"role": "user", "content": "Key features of MLflow?"}],
)
Python
import mlflow
import dspy
mlflow.dspy.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/dspy-tracing-demo")
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
class SimpleSignature(dspy.Signature):
input_text: str = dspy.InputField()
output_text: str = dspy.OutputField()
result = dspy.Predict(SimpleSignature)(input_text="Summarize MLflow Tracing.")
Python
import mlflow
import boto3
mlflow.bedrock.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/bedrock-tracing-demo")
bedrock = boto3.client(service_name="bedrock-runtime", region_name="us-east-1")
response = bedrock.converse(
modelId="anthropic.claude-3-5-sonnet-20241022-v2:0",
messages=[{"role": "user", "content": "Hello World."}],
)
Python
import mlflow
from autogen import ConversableAgent
import os
mlflow.autogen.autolog()
mlflow.set_tracking_uri("databricks")
mlflow.set_experiment("/Shared/autogen-tracing-demo")
config_list = [{"model": "gpt-4o-mini", "api_key": os.environ.get("OPENAI_API_KEY")}]
assistant = ConversableAgent("assistant", llm_config={"config_list": config_list})
user_proxy = ConversableAgent("user_proxy", human_input_mode="NEVER", code_execution_config=False)
user_proxy.initiate_chat(assistant, message="What is 2+2?")
All integrations
Each page includes prerequisites, configuration options, and examples beyond the quickstart above.
LLM providers
Agent frameworks and orchestrators
Utilities and other
Disable automatic tracing
Python
import mlflow
# Disable for a specific library
mlflow.openai.autolog(disable=True)
# Disable all autologging at once
mlflow.autolog(disable=True)
Additional resources
- Manual and custom tracing — add custom spans when autolog does not capture what you need
- Store OpenTelemetry traces in Unity Catalog — governed, SQL-queryable trace storage for production
- View traces in the Databricks MLflow UI — explore traces in the MLflow UI
- Production monitoring — run scorers on production traces to monitor agent quality
Next step: Manual and custom tracing














