Repository navigation
Add an agent OpenTelemetry tracing example - #1168
PratikDhanave (PratikDhanave) wants to merge 2 commits 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.
💡 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.", |
This comment has been minimized.
This comment has been minimized.
# Conflicts: # cmd/verifyexamples/examples.go
API consistency review
Changed Go contractNo exported Go APIs or runtime behavior changed. The PR adds a new example, Upstream evidence reviewedAssessmentThe diff only adds a new example demonstrating OpenTelemetry tracing for an agent run via the existing Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "github.com"See Network Configuration for more information.
|


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.