Add OpenTelemetry GenAI instrumentation to Copilot SDK#602
Open
stephentoub wants to merge 1 commit intogithub:mainfrom
Open
Add OpenTelemetry GenAI instrumentation to Copilot SDK#602stephentoub wants to merge 1 commit intogithub:mainfrom
stephentoub wants to merge 1 commit intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds built-in, opt-in OpenTelemetry tracing + metrics across the SDKs (Node/TS, Python, Go, .NET), emitting spans/metrics that follow the GenAI semantic conventions (v1.40) for agent turns and tool executions.
Changes:
- Introduces
TelemetryConfigin each SDK and wires it into client/session creation (opt-in). - Instruments
invoke_agentturns andexecute_toolcalls with spans + GenAI metrics (duration, token usage, streaming timing). - Updates docs and adds/updates tests demonstrating expected telemetry output and sensitive-data gating.
Reviewed changes
Copilot reviewed 35 out of 37 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/pyproject.toml | Adds OpenTelemetry API/SDK deps (API runtime, SDK in dev extras). |
| python/copilot/types.py | Adds TelemetryConfig + agent attribution fields to session configs. |
| python/copilot/session.py | Starts/updates per-turn telemetry tracking and captures tool descriptions. |
| python/copilot/client.py | Initializes telemetry (opt-in), passes context to sessions, instruments tool calls. |
| python/copilot/_copilot_telemetry.py | Implements Python-side GenAI OTel spans/metrics + per-turn tracker. |
| python/copilot/init.py | Exposes TelemetryConfig from the Python package API surface. |
| python/README.md | Documents telemetry and agent attribution options for Python users. |
| nodejs/test/opentelemetry.test.ts | Adds unit tests validating Node telemetry spans/metrics and gating behavior. |
| nodejs/src/types.ts | Adds TelemetryConfig + agent attribution fields to TS public types. |
| nodejs/src/session.ts | Adds per-turn telemetry tracking hooks and tool description registry. |
| nodejs/src/index.ts | Re-exports TelemetryConfig type. |
| nodejs/src/copilot-telemetry.ts | Implements Node-side GenAI OTel spans/metrics + per-turn tracker. |
| nodejs/src/client.ts | Initializes telemetry (opt-in) and instruments tool execution with child spans + metrics. |
| nodejs/package.json | Adds OTel JS API dependency and SDK devDependencies for tests. |
| nodejs/package-lock.json | Locks new OTel dependencies. |
| nodejs/README.md | Documents telemetry + agent attribution options for Node users. |
| go/types.go | Adds telemetry + agent attribution fields to Go options/config types. |
| go/session.go | Adds tool descriptions + per-turn telemetry hooks and session telemetry context setup. |
| go/go.sum | Adds sums for new OpenTelemetry Go dependencies. |
| go/go.mod | Adds OpenTelemetry Go modules and toolchain metadata. |
| go/copilot_telemetry_consts.go | Defines GenAI semconv constants + metric bucket boundaries for Go. |
| go/copilot_telemetry.go | Implements Go-side GenAI OTel spans/metrics + per-turn tracker. |
| go/client.go | Wires telemetry into client/session creation and tool execution instrumentation. |
| go/README.md | Documents telemetry + agent attribution options for Go users. |
| dotnet/test/OpenTelemetryTests.cs | Adds E2E tests validating .NET telemetry spans/metrics and gating behavior. |
| dotnet/test/Harness/E2ETestContext.cs | Allows creating clients with/without telemetry in the .NET harness. |
| dotnet/test/GitHub.Copilot.SDK.Test.csproj | Adds in-memory OTel exporter dependency for tests. |
| dotnet/src/Types.cs | Adds TelemetryConfig + agent attribution fields to .NET option/config types. |
| dotnet/src/Session.cs | Integrates per-turn tracker and telemetry completion on send/wait failures. |
| dotnet/src/OpenTelemetryConsts.cs | Adds GenAI semconv constants + metric boundaries for .NET. |
| dotnet/src/CopilotTelemetry.cs | Implements .NET telemetry (ActivitySource + Meter) and per-turn tracker. |
| dotnet/src/Client.cs | Creates telemetry instance (opt-in), instruments execute_tool, disposes telemetry on shutdown. |
| dotnet/README.md | Documents telemetry + agent attribution options for .NET users. |
| docs/opentelemetry-instrumentation.md | Rewrites OTel docs to describe built-in instrumentation and configuration. |
| README.md | Adds top-level docs link to OpenTelemetry instrumentation guide. |
Files not reviewed (1)
- nodejs/package-lock.json: Language not supported
7b567d1 to
5e4ddfa
Compare
Introduced built-in OpenTelemetry tracing and metrics for agent turns and tool executions, following GenAI semantic conventions (v1.40). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5e4ddfa to
4b1126f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduced built-in OpenTelemetry tracing and metrics for agent turns and tool executions, following GenAI semantic conventions (v1.40).