Skip to content

Add experimental GitHub telemetry redirection across all SDKs#1835

Open
MackinnonBuck wants to merge 16 commits into
mainfrom
mackinnonbuck-sdk-github-telemetry-contract
Open

Add experimental GitHub telemetry redirection across all SDKs#1835
MackinnonBuck wants to merge 16 commits into
mainfrom
mackinnonbuck-sdk-github-telemetry-contract

Conversation

@MackinnonBuck

Copy link
Copy Markdown
Collaborator

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 onGitHubTelemetry callback (per-language naming) and a hand-written opt-in: when a host registers a handler, the client sets enableGitHubTelemetryRedirection on every session it creates or resumes, and dispatches each gitHubTelemetry.event notification to the callback.

Key pieces:

  • Generated types. Regenerated the RPC types in all languages from the new schema (GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, and the gitHubTelemetry.event clientGlobal method). The shared codegen change adds a notification flag to RpcMethod so generators emit notification-style dispatch (no JSON-RPC reply) for void clientGlobal methods.
  • Hand-written glue. Each SDK surfaces the callback using its existing 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.
  • Tests. Real-wire tests per language verify the handler fires with a correctly typed payload and that the opt-in flag is present when a handler is registered and omitted otherwise.

Notable decisions

  • One commit per language (plus a small shared codegen-infra commit for 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 shared utils.ts change is purely additive (an optional notification? field), so it stays put and never breaks the remaining generators.
  • "Unadvertised" where the language supports it. C# uses [EditorBrowsable(EditorBrowsableState.Never)] and Rust uses #[doc(hidden)]. Languages without a true "exported but hidden" mechanism stay visible + experimental with minimal docs.
  • No public docs. The types are internal/experimental by design.

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.

MackinnonBuck and others added 8 commits June 29, 2026 14:01
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>
Comment thread rust/src/router.rs Dismissed
@github-actions

This comment has been minimized.

Comment thread dotnet/test/Unit/GitHubTelemetryTests.cs Fixed
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>
@github-actions

This comment has been minimized.

MackinnonBuck and others added 2 commits June 30, 2026 12:24
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
@MackinnonBuck MackinnonBuck marked this pull request as ready for review June 30, 2026 19:38
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner June 30, 2026 19:38
Copilot AI review requested due to automatic review settings June 30, 2026 19:38
Comment thread python/test_client.py Fixed

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.

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

Comment thread nodejs/src/client.ts Outdated
Comment thread nodejs/src/client.ts Outdated
Comment thread nodejs/src/client.ts
Comment thread nodejs/src/types.ts Outdated
Comment thread nodejs/test/client.test.ts Outdated
Comment thread python/copilot/_jsonrpc.py Outdated
MackinnonBuck and others added 3 commits June 30, 2026 12:56
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>
@github-actions

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>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds the experimental GitHub telemetry forwarding feature across all six SDK implementations. Overall, it maintains excellent cross-SDK consistency.

What's consistent ✅

Aspect Node.js Python Go .NET Java Rust
Option name onGitHubTelemetry on_github_telemetry OnGitHubTelemetry OnGitHubTelemetry setOnGitHubTelemetry on_github_telemetry
Wire flag in create/resume
Experimental annotation
Generated types exported
Adapter pattern

All naming follows each language's conventions (camelCase/snake_case/PascalCase/bean-style). The enableGitHubTelemetryForwarding wire flag is set consistently in both createSession and resumeSession across all SDKs. Nice use of per-language hide mechanisms (C#'s [EditorBrowsable(Never)], Rust's #[doc(hidden)]).

Minor observation: error handling in callback dispatch

There's a small inconsistency in how user-callback exceptions are handled across SDKs:

  • Node.js: try { await callback(...) } catch { /* silent */ } — silently swallowed
  • Go: defer func() { recover() }() — panics recovered
  • Python: Caught by the underlying _dispatch_notification logging layer — safe
  • Java: catch (Exception e) { LOG.log(Level.SEVERE, ...) } — logged
  • .NET (GitHubTelemetryAdapter.EventAsync): No try/catch at the adapter level — exception propagates up to the RPC dispatch layer

This isn't a blocking issue (the .NET RPC layer may handle it upstream, and the telemetry path is "best-effort" by nature), but it's worth noting for consistency. If a user's OnGitHubTelemetry Action throws in .NET, the behavior differs from other SDKs that swallow or log the error.

Summary

This is a well-implemented, genuinely cross-language feature addition. All SDKs have feature parity and consistent API design. No blocking consistency issues found.

Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.2M ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants