docs: Add MLflow tracing example for voice agents#4972
docs: Add MLflow tracing example for voice agents#4972B-Step62 wants to merge 1 commit intolivekit:mainfrom
Conversation
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>
|
|
| os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = os.getenv( | ||
| "OTEL_EXPORTER_OTLP_HEADERS", f"x-mlflow-experiment-id={experiment_id}" | ||
| ) |
There was a problem hiding this comment.
🟡 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.
| 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}" |
Was this helpful? React with 👍 or 👎 to provide feedback.
Add
mlflow_trace.pyexample 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/