From c4d94e69560a4d7c606cc7a350d34f19e5e8329f Mon Sep 17 00:00:00 2001 From: NekoPunch Date: Fri, 4 Sep 2026 21:18:35 -0700 Subject: [PATCH] docs(python): add MLflow observability example --- .../samples/02-agents/observability/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/python/samples/02-agents/observability/README.md b/python/samples/02-agents/observability/README.md index 201a717e78..822006b17d 100644 --- a/python/samples/02-agents/observability/README.md +++ b/python/samples/02-agents/observability/README.md @@ -155,6 +155,23 @@ os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "" enable_sensitive_telemetry() ``` +Or with [MLflow](https://mlflow.org/docs/latest/genai/tracing/integrations/listing/microsoft-agent-framework/), which ingests traces over OTLP/HTTP at `/v1/traces` and routes them to an experiment via a header. MLflow accepts traces only, so pass a span exporter rather than a base `OTEL_EXPORTER_OTLP_ENDPOINT` (which would also aim log and metric exporters at endpoints MLflow does not serve): + +```python +from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter +from agent_framework.observability import configure_otel_providers, enable_sensitive_telemetry + +# Start a tracking server first, e.g. `mlflow server --backend-store-uri sqlite:///mlflow.db --port 5000` +exporter = OTLPSpanExporter( + endpoint="http://localhost:5000/v1/traces", + headers={"x-mlflow-experiment-id": ""}, +) +configure_otel_providers(exporters=[exporter]) + +# Optional: opt in to capturing sensitive data +enable_sensitive_telemetry() +``` + **4. Manual setup** For full control, set up providers and exporters yourself. See [advanced_manual_setup_console_output.py](./advanced_manual_setup_console_output.py) for a complete example that sends traces, logs, and metrics to the console. The `create_resource()` helper in `agent_framework.observability` can build a resource with the appropriate service name and version from environment variables (or sensible defaults), although the sample does not use it.