Add an agent OpenTelemetry tracing example - #1168
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Conversation
Go has otelprovider but no sample. Add an example that installs a stdout OpenTelemetry tracer and wraps a Foundry agent with the otel middleware, so the agent run emits a gen_ai invoke_agent span (model, usage, finish reason) printed to stdout. Registered with cmd/verifyexamples (env-gated).
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The example description claims a model attribute that the middleware does not emit.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Adds an OpenTelemetry tracing example for Foundry agents and registers it with verifyexamples.
Changes:
- Exports agent spans to stdout.
- Registers environment-gated example verification.
| File | Description |
|---|---|
examples/02-agents/observability/step01_agent_tracing/main.go |
New agent tracing sample |
cmd/verifyexamples/examples.go |
Registers the sample for verification |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "This sample shows how to trace an agent run with OpenTelemetry. The otelprovider "+ | ||
| "middleware emits a gen_ai invoke_agent span (model, usage, finish reason) that "+ | ||
| "is exported here to stdout.", |
|
Scope: examples, tooling (internal-only) Changed Go contract: None. This PR only adds a new example ( Upstream evidence reviewed:
Result: Aligned. The new Go example fills a real coverage gap (Go had no observability sample even though
|

Go has
otelprovider(an OpenTelemetry tracing middleware) butexamples/has no sample, unlike the .NETAgentOpenTelemetrysample.Change
examples/02-agents/observability/step01_agent_tracingthat installs a stdout OpenTelemetry tracer (stdouttrace, already a dependency) as the global provider and wraps a Foundry agent withotelprovider.NewMiddleware, so the run emits agen_aiinvoke_agentspan (model, usage, finish reason) printed to stdout.cmd/verifyexamples(env-gated onFOUNDRY_PROJECT_ENDPOINT).Builds,
go vet,gofumptclean; nogo.modchanges; theverifyexamplestest passes.