Skip to content

docs: Add MLflow tracing example for voice agents#4972

Open
B-Step62 wants to merge 1 commit intolivekit:mainfrom
B-Step62:add-mlflow-tracing-example
Open

docs: Add MLflow tracing example for voice agents#4972
B-Step62 wants to merge 1 commit intolivekit:mainfrom
B-Step62:add-mlflow-tracing-example

Conversation

@B-Step62
Copy link

Add mlflow_trace.py example that demonstrates how to send OpenTelemetry traces from LiveKit Agents to MLflow's tracking server, following the structure of other tracing providers. MLflow is an open-source LLMOps platform with 30MM monthly download.

Doc on MLflow side: https://mlflow.org/docs/latest/genai/tracing/integrations/listing/livekit/

Add mlflow_trace.py example that demonstrates how to send
OpenTelemetry traces from LiveKit Agents to MLflow's tracking
server. Follows the same pattern as the existing langfuse_trace.py.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +62 to +64
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = os.getenv(
"OTEL_EXPORTER_OTLP_HEADERS", f"x-mlflow-experiment-id={experiment_id}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 experiment_id parameter silently ignored when OTEL_EXPORTER_OTLP_HEADERS env var is set

When a user calls setup_mlflow(experiment_id="5") but the OTEL_EXPORTER_OTLP_HEADERS environment variable is already set, the explicitly passed experiment_id parameter is silently ignored.

Root Cause

On line 58, experiment_id is resolved from the parameter (or defaults to "0"). But on lines 62-63, the code does:

os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = os.getenv(
    "OTEL_EXPORTER_OTLP_HEADERS", f"x-mlflow-experiment-id={experiment_id}"
)

This means if OTEL_EXPORTER_OTLP_HEADERS is already set in the environment, the env var value takes precedence and the experiment_id parameter is discarded. This is inconsistent with how endpoint works on line 57, where the parameter takes precedence over the env var via endpoint = endpoint or os.getenv(...).

Impact: A user explicitly passing experiment_id would expect it to be used, but traces could be sent to the wrong MLflow experiment if OTEL_EXPORTER_OTLP_HEADERS is already set in the environment.

Suggested change
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = os.getenv(
"OTEL_EXPORTER_OTLP_HEADERS", f"x-mlflow-experiment-id={experiment_id}"
)
if "OTEL_EXPORTER_OTLP_HEADERS" not in os.environ:
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"x-mlflow-experiment-id={experiment_id}"
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants