Add an agent OpenTelemetry tracing example by PratikDhanave · Pull Request #1168 · microsoft/agent-framework-go · GitHub
Skip to content

Add an agent OpenTelemetry tracing example - #1168

Open
PratikDhanave (PratikDhanave) wants to merge 2 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/example-otel
Open

PratikDhanave (PratikDhanave) wants to merge 2 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/example-otel

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Go has otelprovider (an OpenTelemetry tracing middleware) but examples/ has no sample, unlike the .NET AgentOpenTelemetry sample.

Change

  • New examples/02-agents/observability/step01_agent_tracing that installs a stdout OpenTelemetry tracer (stdouttrace, already a dependency) as the global provider and wraps a Foundry agent with otelprovider.NewMiddleware, so the run emits a gen_ai invoke_agent span (model, usage, finish reason) printed to stdout.
  • Registered in cmd/verifyexamples (env-gated on FOUNDRY_PROJECT_ENDPOINT).

Builds, go vet, gofumpt clean; no go.mod changes; the verifyexamples test passes.

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).
Copilot AI lite review requested due to automatic review settings September 23, 2026 04:52
@github-actions github-actions Bot added area:examples Changes files in the examples area area:tooling Changes files in the tooling area size:medium At most 100 changed lines across at most 5 files labels Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Low severity

Open (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.

Comment on lines +19 to +21
"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.",
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the kind:examples Changes examples or example-support metadata label Sep 23, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Sep 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 29, 2026
# Conflicts:
#	cmd/verifyexamples/examples.go
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned examples

Changed Go contract

No exported Go APIs or runtime behavior changed. The PR adds a new example, examples/02-agents/observability/step01_agent_tracing/main.go, and registers it in cmd/verifyexamples/examples.go. The example uses only existing public APIs (otelprovider.NewMiddleware, foundryprovider.NewAgent, agent.Config) that were already exercised by examples/02-agents/agents/step08_observability/main.go.

Upstream evidence reviewed

Implementation Source Contract checked
Go (in-repo) examples/02-agents/agents/step08_observability/main.go Existing sample already demonstrates the same otelprovider.NewMiddleware + stdout trace exporter pattern for a Foundry agent, confirming this new example is a restructured/simplified duplicate using only previously-reviewed public surface.

Assessment

The diff only adds a new example demonstrating OpenTelemetry tracing for an agent run via the existing otelprovider.NewMiddleware and foundryprovider.NewAgent APIs, plus its corresponding verifyexamples registration entry. No exported types, functions, defaults, or observable framework behavior are introduced or modified; the example composes already-shipped public APIs in the same way a sibling example (step08_observability) does. No parity concerns apply since this is additive sample content, not a new capability requiring upstream comparison.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent · copilot · auto · 28.3 AIC · ⌖ 7.35 AIC · ⊞ 13.9K · ◷

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Oct 3, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Oct 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:examples Changes files in the examples area area:tooling Changes files in the tooling area kind:examples Changes examples or example-support metadata parity-approved Go API consistency review found no parity issues size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants