Skip to content

Add an agent OpenTelemetry tracing example - #1168

Merged
Quim Muntal (qmuntal) merged 3 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/example-otel
Nov 4, 2026
Merged

Quim Muntal (qmuntal) merged 3 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.

@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

This comment has been minimized.

@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
# Conflicts:
#	cmd/verifyexamples/examples.go
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned examples

Changed Go contract

None to exported APIs. Adds the sample examples/02-agents/observability/step01_agent_tracing, which wraps a Foundry agent with otelprovider.NewMiddleware. The sample is registered in cmd/verifyexamples.

Upstream evidence reviewed

Implementation Source Contract checked
.NET dotnet/samples/02-agents/AgentOpenTelemetry Agent tracing sample exists upstream
Python python/samples/02-agents/observability/ (agent_observability.py, foundry_agent_tracing.py) Observability sample folder with agent tracing exists upstream

Assessment

Both upstream SDKs have an agent tracing sample, and the Go sample covers the same scenario. It is placed under a matching observability folder. No exported API or default changed, so there are no parity issues. I only compared the sample folders and names. I did not read upstream sample contents, because the code search API was rate-limited. public-api-change is not applicable.

Generated by Go API Consistency Review Agent · copilot · auto · 17.3 AIC · ⌖ 0.616 AIC · ⊞ 5.1K · ◷

@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Nov 4, 2026
Merged via the queue into microsoft:main with commit 4a2cede Nov 4, 2026
23 checks passed
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