Chat: OTel enrichment for Claude agent sessions#318472
Merged
Merged
Conversation
3e1d69f to
b169da7
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the Copilot extension’s canonical github.copilot.* OpenTelemetry enrichment to the Claude agent session flow so Claude invoke_agent / execute_tool / execute_hook spans become queryable on the same dimensions as built-in Copilot Chat spans.
Changes:
- Enriches Claude
invoke_agentspans withgithub.copilot.agent.typeand workspace git/GitHub org attributes via workspace metadata resolution. - Emits structured
github.copilot.tool.parameters.*attributes for Claude tool calls usingextractToolParameters, with content-sensitive fields gated behindcaptureContent. - Records hook completion attributes (
github.copilot.hook.decision,github.copilot.hook.duration) and extends tool-name classification to Claude’s capitalized tool names.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/otel/node/test/extractToolParameters.spec.ts | Adds coverage for Claude-capitalized tool-name classification. |
| extensions/copilot/src/platform/otel/node/extractToolParameters.ts | Extends edit-type classification to Claude tool names. |
| extensions/copilot/src/platform/otel/common/genAiAttributes.ts | Adds Claude tool names to shell/file tool-name sets used by OTel extraction. |
| extensions/copilot/src/extension/chatSessions/claude/node/claudeOTelTracker.ts | Adds canonical Copilot git/org/agent-type attributes to Claude root spans. |
| extensions/copilot/src/extension/chatSessions/claude/node/claudeCodeAgent.ts | Wires additional per-request timing state for hook duration tracking. |
| extensions/copilot/src/extension/chatSessions/claude/common/test/claudeMessageDispatch.spec.ts | Adds tests for tool parameter emission and hook decision/duration attributes. |
| extensions/copilot/src/extension/chatSessions/claude/common/claudeMessageDispatch.ts | Emits tool parameter attributes and hook decision/duration attributes on spans. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 1
DonJayamanne
previously approved these changes
May 27, 2026
Member
Author
|
Pushed 55224ab to fix CI:
89 tests pass; typecheck clean (the unrelated |
dmitrivMS
approved these changes
May 27, 2026
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.
Overview
Follow-up to #318031, which introduced the canonical
github.copilot.*OTel attribute namespace on the foreground Copilot Chat agent. This PR extends the same enrichment to Claude Code agent sessions so traces carry parity attributes across agent surfaces.What
invoke_agent claude(claudeOTelTracker) — now emits:github.copilot.agent.type: 'builtin'github.copilot.git.{repository,branch,commit_sha}andgithub.copilot.github.org(viaworkspaceMetadataToOTelAttributes(resolveWorkspaceOTelMetadata(gitService)), mirroringtoolCallingLoop).execute_toolfor Claude tool calls (claudeMessageDispatch.handleAssistantMessage) — now uses an injected tool-parameter extractor (node-layer provided) to emit:github.copilot.tool.parameters.edit_type,skill_name,mcp_server_name_hash,mcp_tool_name.captureContent):command,file_path,mcp_server_name.execute_hook(claudeMessageDispatch.handleHookResponse) — now emits:github.copilot.hook.decision—pass(outcomesuccess) /block(exit code 2) /non_blocking_error(other failure).github.copilot.hook.duration— seconds, measured betweenhookStartedandhookResponsevia a newhookStartTimesmap onMessageHandlerState.extractToolParameters/genAiAttributes— added Claude tool-name aliases so the classifier recognisesBash,Read,Edit,MultiEdit,Write,NotebookEdit.gen_ai.tool.call.argumentsnow truncates withotelService.config.maxAttributeSizeCharsto avoid oversized OTel attributes being dropped.Why
After #318031, dashboards built on the canonical
github.copilot.*namespace were missing rows for the Claude agent path — itsinvoke_agent/execute_tool/execute_hookspans were only partially queryable. This brings Claude to parity with the built-in agent's enrichment while preserving extension layering constraints.Backwards compatibility
All existing attributes (
gen_ai.*,copilot_chat.*) remain unchanged. Only additive attribute writes; no behavioural change to dispatch or hook handling.Docs
Updated
extensions/copilot/docs/monitoring/:agent_monitoring.md— Claudeinvoke_agent claudeattribute table now lists the newgithub.copilot.{agent.type,git.*,github.org}keys; added a proper attribute table for Claudeexecute_toollistingtool.parameters.*.agent_monitoring_arch.md— corrected thegithub.copilot.*namespace description to reflect that it's the canonical Copilot namespace (extension-emitted enrichment + CLI SDK internal metrics), not just SDK-internal.Tests
extractToolParameters.spec.ts— adds Claude-name classification (Bash, Read, Edit, MultiEdit, Write, NotebookEdit).claudeMessageDispatch.spec.ts— addshook.decision/hook.durationcases andtool.parameters.*emission.claudeCodeAgentOTel.spec.ts— exercised via existing end-to-end coverage.