Add experimental GitHub telemetry redirection across all SDKs#1835
Conversation
Adds an optional otification marker to the shared RpcMethod interface so the per-language generators can emit notification-style dispatch (no JSON-RPC reply) for void clientGlobal methods such as gitHubTelemetry.event. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the TypeScript RPC types for the experimental gitHubTelemetry.event clientGlobal notification and wires an onGitHubTelemetry callback on the client. Registering a handler opts created/resumed sessions into telemetry redirection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the C# RPC types for the experimental gitHubTelemetry.event clientGlobal notification and adds an OnGitHubTelemetry callback. Registering a handler opts created/resumed sessions into telemetry redirection. The option is marked [Experimental] and [EditorBrowsable(Never)] to keep it unadvertised. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Python RPC types for the experimental gitHubTelemetry.event clientGlobal notification and adds an on_github_telemetry callback. Registering a handler opts created/resumed sessions into telemetry redirection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Go RPC types for the experimental gitHubTelemetry.event clientGlobal notification and adds an OnGitHubTelemetry callback. Registering a handler opts created/resumed sessions into telemetry redirection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Rust RPC types for the experimental gitHubTelemetry.event clientGlobal notification and adds an on_github_telemetry callback. Registering a handler opts created/resumed sessions into telemetry redirection. The telemetry module is #[doc(hidden)] to keep it unadvertised. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the experimental gitHubTelemetry.event notification adapter and an onGitHubTelemetry client option. Registering a handler opts created/resumed sessions into telemetry redirection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolves conflicts in two generated files where main's @github/copilot 1.0.66-2 bump added new RPC types (GitHubRepoRef, user settings, mcp headers, push attachments, etc.) adjacent to this branch's GitHubTelemetry* types: - go/rpc/zrpc.go: union of both sides' struct declarations. - python/copilot/generated/rpc.py: union of __all__ exports and reconstruction of the RPC.from_dict positional constructor call from the (auto-merged) assignment order, verified to match the RPC dataclass field order (795 fields). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Keep experimental GitHub telemetry schema additions available to codegen until they ship in the packaged Copilot schema, and apply formatter output required by CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The runtime renamed the per-session opt-in capability from "redirection" to "forwarding" (wire field enableGitHubTelemetryForwarding) and updated the GitHubTelemetry schema description strings. This mirrors that rename across every SDK plus the codegen schema overlay so the hand-written opt-in flag matches the runtime contract. Also folds in two PR review fixes: - dotnet: document the expected-teardown catch in GitHubTelemetryTests DisposeAsync (was an empty catch). - python: re-export GitHubTelemetryNotification/Event/ClientInfo from copilot/__init__.py for parity with the nodejs public surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hub-telemetry-contract # Conflicts: # go/client_test.go
There was a problem hiding this comment.
Pull request overview
Implements an experimental cross-SDK surface for receiving per-session GitHub (hydro) telemetry forwarded by the runtime via a new JSON-RPC client-global notification (gitHubTelemetry.event). The PR extends shared codegen to understand notification-style RPC methods and wires opt-in + dispatch behavior across TypeScript/Node, Python, Go, Rust, Java, and .NET, with tests validating forwarding and handler invocation.
Changes:
- Added schema override + shared codegen support for notification-style client-global methods (
RpcMethod.notification) and for injecting additive API schema entries during schema loading. - Implemented per-SDK “on GitHub telemetry” callback wiring and session create/resume opt-in (
enableGitHubTelemetryForwarding) when a handler is registered. - Added/updated unit/integration tests across SDKs to validate handler dispatch and the opt-in flag behavior.
Show a summary per file
| File | Description |
|---|---|
| scripts/codegen/utils.ts | Loads API schema and applies additive overrides; adds notification?: boolean to RpcMethod. |
| scripts/codegen/typescript.ts | Emits onNotification wiring for notification-style client-global methods. |
| scripts/codegen/schema-overrides/api-additions.schema.json | Adds gitHubTelemetry.event + telemetry types via additive schema override (marked notification + experimental). |
| scripts/codegen/rust.ts | Switches schema loading to shared loadSchemaJson (enabling overrides). |
| scripts/codegen/python.ts | Emits notification-handler wiring for notification-style client-global methods. |
| scripts/codegen/go.ts | Adjusts Go codegen for client-global void/notification methods and emits notification-safe handler signatures. |
| rust/src/github_telemetry.rs | New Rust module re-exporting telemetry types + callback alias (doc-hidden). |
| rust/src/lib.rs | Adds client option + plumbing for telemetry callback; adds test constructor helper. |
| rust/src/router.rs | Routes gitHubTelemetry.event client-global notifications to callback (if set). |
| rust/src/session.rs | Sets enableGitHubTelemetryForwarding on create/resume when callback registered. |
| rust/src/types.rs | Initializes new wire fields to None in config→wire conversion. |
| rust/src/wire.rs | Adds enableGitHubTelemetryForwarding wire field to create/resume request DTOs. |
| rust/src/generated/api_types.rs | Generated telemetry DTOs. |
| rust/tests/session_test.rs | Rust integration tests validating opt-in flag and callback dispatch. |
| python/copilot/_jsonrpc.py | Adds method-specific notification handler registry + dispatch path. |
| python/copilot/generated/rpc.py | Generated telemetry DTOs + client-global notification handler registration for gitHubTelemetry.event. |
| python/copilot/client.py | Adds on_github_telemetry option, opt-in flag wiring, and registers client-global handlers. |
| python/copilot/init.py | Re-exports telemetry DTOs at package level. |
| python/test_client.py | Python unit tests for opt-in flag and notification dispatch path. |
| nodejs/src/generated/rpc.ts | Generated telemetry DTOs + onNotification registration for gitHubTelemetry.event. |
| nodejs/src/types.ts | Exposes telemetry DTOs and adds onGitHubTelemetry option type. |
| nodejs/src/index.ts | Re-exports telemetry DTO types from the public entrypoint. |
| nodejs/src/client.ts | Wires onGitHubTelemetry, registers client-global handlers, and sets session opt-in flag. |
| nodejs/test/client.test.ts | Node tests for opt-in flag behavior and notification dispatch. |
| go/rpc/zrpc.go | Generated Go telemetry DTOs + client-global handler interface + registration. |
| go/types.go | Adds OnGitHubTelemetry client option and wire fields on create/resume DTOs. |
| go/client.go | Sets opt-in flag on create/resume and registers telemetry callback adapter. |
| go/client_test.go | Go tests validating opt-in flag serialization and notification routing to callback. |
| java/src/main/java/com/github/copilot/GitHubTelemetryAdapter.java | Java adapter bridging gitHubTelemetry.event into consumer callback. |
| java/src/main/java/com/github/copilot/CopilotClient.java | Registers telemetry adapter on connect; sets opt-in flag on create/resume when handler set. |
| java/src/main/java/com/github/copilot/rpc/CopilotClientOptions.java | Adds experimental setOnGitHubTelemetry option and clones it. |
| java/src/main/java/com/github/copilot/rpc/CreateSessionRequest.java | Adds enableGitHubTelemetryForwarding field + accessors. |
| java/src/main/java/com/github/copilot/rpc/ResumeSessionRequest.java | Adds enableGitHubTelemetryForwarding field + accessors. |
| java/src/main/java/com/github/copilot/rpc/GitHubTelemetryClientInfo.java | Java telemetry DTO. |
| java/src/main/java/com/github/copilot/rpc/GitHubTelemetryEvent.java | Java telemetry DTO. |
| java/src/main/java/com/github/copilot/rpc/GitHubTelemetryNotification.java | Java telemetry DTO. |
| java/src/test/java/com/github/copilot/GitHubTelemetryTest.java | Java tests verifying adapter dispatch and opt-in flag on create/resume. |
| dotnet/src/Generated/Rpc.cs | Generated telemetry DTOs + client-global handler interface and registration. |
| dotnet/src/Types.cs | Adds hidden experimental OnGitHubTelemetry option to CopilotClientOptions. |
| dotnet/src/Client.cs | Sets opt-in flag when handler present; registers telemetry adapter in client-global handlers. |
| dotnet/test/Unit/GitHubTelemetryTests.cs | .NET unit tests validating opt-in behavior and notification forwarding. |
Review details
Files not reviewed (1)
- go/rpc/zrpc.go: Generated file
- Files reviewed: 36/41 changed files
- Comments generated: 6
- Review effort level: Low
Address PR review feedback on the Node telemetry surface: - Omit enableGitHubTelemetryForwarding from session.create/resume unless a handler is registered, matching Go/Python/Rust/dotnet/Java (which all omit the field when off) instead of always sending false. - Isolate consumer callback failures: await the handler inside try/catch so async callbacks or thrown errors cannot leak into the JSON-RPC dispatch path (mirrors the panic isolation in the other SDKs). - Widen onGitHubTelemetry to return void | Promise<void> so consumers can supply async callbacks. - Update the no-handler test to assert the field is absent rather than false. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use asyncio.create_task instead of the legacy asyncio.ensure_future when scheduling awaitable notification handlers on the event loop thread. - Drop the redundant local `import asyncio` in the telemetry transport test (asyncio is already imported at module scope), clearing CodeQL py/repeated-import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The DisposeAsync teardown catch swallows expected listener/socket shutdown exceptions. Observe the caught exception so the block is no longer empty, clearing CodeQL cs/empty-catch-block. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Brings in the @github/copilot 1.0.66 bump (#1859), which re-ran the code generators and added new RPC/session types (SessionLimits*, SessionCompletions, AdaptiveThinkingSupport, etc.). Conflicts were limited to generated files (dotnet Rpc.cs, python rpc.py). Resolved by installing 1.0.66 and re-running `scripts/codegen` with the telemetry schema overlay, so every generated file is a consistent product of the 1.0.66 schema plus the experimental GitHub telemetry additions rather than a hand-merged blend. Verified 1.0.66 still does not ship the telemetry types, so the overlay remains required. Codegen is idempotent (re-running produces no diff) and the hand-written telemetry glue (including the Node conditional-spread opt-in) is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The telemetry types ship natively in @github/copilot 1.0.67, so the hand-maintained schema overlay that injected GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, and the gitHubTelemetry.event clientGlobal method is no longer needed. Remove the api-additions overlay and its application plumbing in utils.ts, and revert rust.ts to read the schema directly. The generic notification-flag codegen handling is retained, since the published schema marks gitHubTelemetry.event as a notification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The clientGlobal method gitHubTelemetry.event is a JSON-RPC notification (schema notification: true, void result). Restore the codegen notification-flag machinery so TypeScript/Python/Go emit notification registration (onNotification / notification-handler table / nil-result SetRequestHandler) instead of request-style onRequest dispatch, and regenerate the affected bindings. Also restore the Python _jsonrpc notification registry and fix the Go adapter to return only an error. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Send an id-less JSON-RPC notification (not a request) through the real wire in the Node and Python unit tests so a regression back to onRequest dispatch is caught. Add a Node E2E that creates a forwarding-enabled session against a live CLI and asserts a gitHubTelemetry.event notification is delivered to the onGitHubTelemetry handler. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Adds a live-CLI E2E in Go, Python, .NET, Rust, and Java that registers an onGitHubTelemetry callback, creates a session, and asserts at least one gitHubTelemetry.event notification is forwarded with a well-typed payload. This brings the other SDKs to parity with the existing nodejs E2E. Session creation emits an early session.start hydro event, so no model round-trip (and no recorded CAPI exchange) is needed; the tests are snapshot-free. The Rust change also refactors the E2E harness to run a native COPILOT_CLI_PATH binary directly (non-.js), leaving the node_modules index.js path unchanged for CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 1.7M
Wrap the user-provided on_github_telemetry / OnGitHubTelemetry callback invocation in exception handling so a throwing handler cannot propagate into the JSON-RPC dispatch machinery. Mirrors the existing guards in the Node, Go, Java, and Rust adapters. Errors are logged (Python module logger; .NET ILogger, falling back to NullLogger.Instance) rather than silently swallowed, matching the Java (SEVERE) and Rust (warn) behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.7M
A user-supplied onGitHubTelemetry callback throwing is a routine, recoverable condition, not a serious system failure. Level.WARNING matches the Java SDK''s own convention (CopilotSession "Error in event handler") and the .NET (LogWarning) and Rust (warn) adapters. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.6M
A user-supplied on_github_telemetry callback throwing is a routine, recoverable condition, not an error. Use logger.warning(..., exc_info=True) instead of logger.exception (which logs at ERROR), matching the .NET, Java, and Rust adapters and client.py''s own convention (exc_info=True elsewhere, never logger.exception). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
The runtime-forwarded gitHubTelemetry.event callback now returns an awaitable so consumers can perform async I/O in their telemetry sink, addressing PR feedback. Signatures: - nodejs: (n) => void | Promise<void> - .NET: Func<GitHubTelemetryNotification, Task> - Java: Function<GitHubTelemetryNotification, CompletableFuture<Void>> - Python: Callable[[GitHubTelemetryNotification], None | Awaitable[None]] Each adapter awaits the result and logs handler failures at WARNING. Go and Rust are intentionally left synchronous; neither SDK has an async-callback idiom. Unit and E2E call sites updated accordingly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅All six SDKs (Node.js, Python, Go, .NET, Java, Rust) are modified in this PR with consistent, feature-parity implementations. Here's a summary of what was verified: Consistent across all SDKs ✅
Language-idiomatic differences (expected, not issues)
No inconsistencies foundThis is a well-executed cross-language feature — the implementation pattern is clearly applied uniformly across all SDKs. Each SDK correctly:
|
Why
The runtime can now forward per-session GitHub (hydro) telemetry to opted-in host connections via a new JSON-RPC server to client notification,
gitHubTelemetry.event. This PR implements the consumer side of that contract in every language SDK so hosts can receive those events. The feature is internal and experimental, so it is intentionally kept low-profile and undocumented for public consumers.What
For each SDK this adds an
onGitHubTelemetrycallback (per-language naming) and a hand-written opt-in: when a host registers a handler, the client setsenableGitHubTelemetryRedirectionon every session it creates or resumes, and dispatches eachgitHubTelemetry.eventnotification to the callback.Key pieces:
GitHubTelemetryNotification,GitHubTelemetryEvent,GitHubTelemetryClientInfo, and thegitHubTelemetry.eventclientGlobal method). The shared codegen change adds anotificationflag toRpcMethodso generators emit notification-style dispatch (no JSON-RPC reply) for void clientGlobal methods.llmInference/ notification idiom and wires the opt-in flag into the create/resume requests. We deliberately reuse the generated RPC types directly rather than introducing friendly wrapper types.Notable decisions
utils.ts). This makes the feature trivially revertible language-by-language: reverting a single language's commit removes its support without touching the others. The sharedutils.tschange is purely additive (an optionalnotification?field), so it stays put and never breaks the remaining generators.[EditorBrowsable(EditorBrowsableState.Never)]and Rust uses#[doc(hidden)]. Languages without a true "exported but hidden" mechanism stay visible + experimental with minimal docs.Review notes
This is the SDK side of a contract whose runtime counterpart is merged-in-progress on the
@github/copilot(copilot-agent-runtime) side. The schema is the source of truth; generated files were produced by codegen, not hand-edited.