One trace for a Workflow and the agent it runs: the starter's root span, the Workflow, Agent Framework's own invoke_agent span, the model Activity, and the OpenAI client's chat span inside that Activity.
Client.connect(plugins=[OpenTelemetryPlugin(add_temporal_spans=True), MicrosoftAgentFrameworkPlugin(...)])on the Worker's Client: tracing first, so the Worker inherits both in that order. The starter's Client carriesOpenTelemetryPluginalone and propagates the trace into the Workflow.create_tracer_provider()fromtemporalio.contrib.opentelemetryas the global provider in both processes, from telemetry.py. Agent Framework starts itsinvoke_agentspan from Workflow code, so the provider has to be replay-safe: Workflow spans keep their ids across replays and are exported once. With a plain SDKTracerProviderthe plugin warns at Worker start, andOpenTelemetryPluginrefuses to start the Worker.- The OpenAI client's own
chat gpt-4o-minispan runs inside the Activity with real timings.
Start a Temporal dev server in one terminal:
temporal server start-devStart Jaeger to receive and show the traces. It takes OTLP on port 4317, the default in telemetry.py; set OTEL_EXPORTER_OTLP_ENDPOINT to send the spans somewhere else:
docker run --rm -p 16686:16686 -p 4317:4317 jaegertracing/all-in-one:latestWithout a collector the Workflow still completes; each process logs an export warning and an export error, and the starter exits a few seconds late.
Then the Worker and the starter, from the repository root:
# Terminal 1
uv run microsoft_agent_framework_plugin/open_telemetry/run_worker.py
# Terminal 2
uv run microsoft_agent_framework_plugin/open_telemetry/run_workflow.pyThe starter prints the result and the trace id:
Result: Durable execution runs code to completion despite failures, by recording progress and resuming from it.
Trace ID: aa8b95b37c1b39f76cc9102fa3d1d5b9
Open http://localhost:16686/trace/<trace ID>. The trace spans two services:
ask-agent microsoft-agent-framework-starter
└─ StartWorkflow:TracedWorkflow microsoft-agent-framework-starter
└─ RunWorkflow:TracedWorkflow microsoft-agent-framework-worker
└─ invoke_agent assistant microsoft-agent-framework-worker
└─ StartActivity:microsoft_agent_framework.invoke_model microsoft-agent-framework-worker
└─ RunActivity:microsoft_agent_framework.invoke_model microsoft-agent-framework-worker
└─ chat gpt-4o-mini microsoft-agent-framework-worker
| File | Description |
|---|---|
telemetry.py |
install_tracer_provider: a replay-safe provider with an OTLP gRPC exporter |
workflow.py |
TracedWorkflow with one named Agent |
run_worker.py |
Both plugins on the Client, starts the Worker |
run_workflow.py |
Starts the Workflow under a root span and prints the trace id |