You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce agent telemetry hook overhead without reducing coverage - #20387
Preserves wildcard agent-hook coverage and all currently eligible Aspire telemetry while removing shell startup and synchronous upload waits.
Both hook and uploader modes run through AgentTelemetryCommand and normal command dispatch. InitializeTelemetryOnStartup defaults to true; the agent command defers provider creation and enrichment until an eligible event exists. Existing first-run and generic invocation-span rules are preserved.
Skill names and reference paths come from the embedded bundle's skill-manifest.json, read in memory with the existing manifest types and source-generated serializer. The shipped inventory preserves all 7 skills and 33 references. MCP tool names still come from the embedded canonical hook because the manifest does not contain a tool inventory.
Hook environment-variable reads use injected IEnvironment; hook tests run in-process without changing global environment state. A documented setting bounds input before parsing.
Eligible telemetry is persisted through Azure Monitor Exporter's existing disk-backed storage. An independent CLI uploader keeps its existing batching/retry machinery alive until the backlog drains.
Legacy Aspire registrations migrate idempotently without removing unrelated user hooks. The latest main merge preserves shell completions and the v0.0.3 skills bundle.
The committed upgrade supersedes closed draft #20042 and consistently uses the newest releases published at least seven days before September 23, 2026:
The 1.19.x releases were too recent for that age requirement and are not the target. The GrpcNetClient approved-feed import succeeded in run 3085688, and full solution restore succeeded against configured feeds. No quarantine was bypassed. Existing Blazor playground-specific overrides from #20339 are unchanged. Seq's generated configuration schema was refreshed for the added OTLP properties.
Breaking changes
OpenTelemetry 1.18 reduces the default maximum serialized OTLP request from 128 MiB to 64 MiB. Oversized batches are dropped. Consumers relying on the previous limit can configure:
The default maximum OTLP response size is 4 MiB. Generated ServiceDefaults inherit updated versions; existing customer projects are not rewritten. Ordinary CLI shutdown behavior is explicitly preserved despite the Azure Monitor upgrade.
User-facing usage
After installing the updated CLI, refresh agent configuration:
aspire agent init
Claude retains matcher: "*"; Copilot retains unfiltered postToolUse. Both directly execute aspire agent telemetry --hook without PowerShell/Bash. Compatibility scripts are taken unchanged from the canonical bundle.
ASPIRE_AGENT_TELEMETRY_MAX_PAYLOAD_CHARACTERS configures the native input bound: default 65,536 UTF-16 characters, range 1–1,048,576. Oversized input is drained without retention; invalid values produce a diagnostic without breaking the agent.
Validation
Review refactor: 370 tests passed, one Linux-only skip, covering startup/completions, normal command routing, deferred provider/enrichment initialization, opt-out, all three event categories, and existing telemetry behavior.
Manifest change: 137 focused tests passed, including archive/JSON validation, canonical reporting-set parity, hook classification, and skills bundle regressions.
Final Windows x64 Native AOT publish passed after the manifest change.
The real cross-process lease-expiry recovery test is now marked [OuterloopTest]; fast persistence and uploader-lifecycle coverage remains in regular CI. The real recovery scenario passed before this scheduling-only change.
Coordinated dependency upgrade: full solution restore, Hosting/template builds, generated ServiceDefaults/MAUI version verification, and 21 Seq tests across .NET 8/9/10 passed. Seq stabilization packaging passed. Restore reported existing unrelated vulnerability advisories.
Real Copilot CLI 1.0.87-0, isolated COPILOT_HOME: postToolUse with exec/args ran its recorder after a view call.
Performance trade-off: normal command dispatch measured 145.4 ms median and 210.7 ms p95 for unrelated native hooks over 25 local Windows launches; the old PowerShell sample was approximately 337–460 ms. The earlier pre-host shortcut measured 52.3 ms median but was removed in response to review. These are direct-process samples, not a zero-cost guarantee.
Linux/macOS runtime performance was not tested locally.
Security considerations
The hook processes bounded untrusted JSON and launches an independent uploader. Catalog inputs come from embedded release-verified resources, not mutable user-installed skills/scripts. Only manifest-listed references/ files are reference events; evals and scripts are excluded. No new listener, ingestion endpoint, raw-payload storage, or telemetry category is introduced. Direct argument vectors avoid shell interpretation. Existing exporter storage and process-isolation helpers are reused. Security review should cover classification parity, configuration ownership, and detached-process lifetime.
Delivery remains subject to disk failures, exporter limits, retention, and permanent ingestion errors. Interrupted uploads may stay leased for several minutes; at-least-once delivery permits duplicates. Environment opt-out applies at process launch, not retroactively to running processes.
Checklist
Is this feature complete?
Yes. Ready to ship.
No. Follow-up changes expected.
Are you including unit tests for the changes and scenario tests if relevant?
Yes
No
Did you add public API?
Yes
If yes, did you have an API Review for it?
Yes
No
Did you add <remarks /> and <code /> elements on your triple slash comments?
Yes
No
No
Does the change make any security assumptions or guarantees?
Yes
If yes, have you done a threat model and had a security review?
OpenTelemetry packages remain on inconsistent mixed versions
eng/Versions.props:57
The coordinated upgrade in the PR description targets OpenTelemetry.Extensions.Hosting 1.19.1 and the rest of the OpenTelemetry family at 1.19.x, but this line sets Hosting to 1.18.0 while the sibling properties remain at 1.17.0 (and the hard-coded Console/InMemory/GrpcNetClient packages are unchanged). This leaves the partial mixed-version upgrade that the PR says it will supersede; update the full family to the stated targets before merging.
Mark three-minute blob lease expiry test as outerloop
This test intentionally waits for the exporter's three-minute blob lease to expire, so leaving it in the regular suite adds at least three minutes to every selected Aspire.Cli.Tests run. Long-running tests are marked OuterloopTest in this project (for example, Mcp/E2E/McpDocsE2ETests.cs:20 and Projects/JavaAppHostToolchainResolverTests.cs:371); mark this test outerloop or replace the wall-clock lease expiry with a deterministic hook.
No test exercises EnsureRunningAsync; the new tests invoke DrainAsync directly. As a result, the critical platform-specific path here—DCP resolution and lease handoff on Unix, detached process startup, command arguments, and environment filtering—can break while all added tests still pass. Add focused launch coverage (including the Unix path) that starts the uploader through EnsureRunningAsync and verifies the child drains persisted data after the producer exits.
Test waits three minutes for real lease expiration
This regular test deliberately waits for Azure Monitor Exporter's three-minute blob lease to expire, so it adds at least three minutes to every Aspire.Cli.Tests run on each platform. That is a substantial CI regression for a single test. Move this scenario to the outer loop (or introduce a test seam that avoids real-time lease expiry).
Include the new OTLP request and response size options for logs and traces so schema validation and dependent CI builds succeed.
Co-authored-by: Copilot App <[email protected]>
The tests exercise DrainAsync directly, but none invokes EnsureRunningAsync; even the cross-process recovery test creates its own RemoteExecutor child. Therefore command construction, Windows detached launch, Unix DCP resolution/layout-lease handoff, and survival after the producer exits can all regress while the suite remains green. Add a process-level test that starts the uploader through this method and verifies the detached child drains persisted data after its producer exits.
Move standard input into ConsoleEnvironment and initialize providers only when the selected command needs them.
Co-authored-by: Copilot <[email protected]>
The new Unix uploader path (DCP resolution, layout-lease handoff, and detached child launch) is not exercised by the added tests: they call DrainAsync directly and never invoke EnsureRunningAsync. A regression here would leave every persisted event queued indefinitely on Linux/macOS even though the in-process drain tests pass. Add an integration/E2E test that persists an event, starts the uploader through this path, lets the producer exit, and verifies the detached --drain process clears the backlog.
Triggered signals (6): cli_command_file_changed (AgentCommand.cs, AgentTelemetryCommand.cs modified), cli_option_added (new hidden --hook Option in AgentTelemetryCommand.cs), pr_body_has_cli_flag_mention (aspire agent telemetry --hook), pr_body_has_user_facing_section (explicit 'User-facing usage' heading describing aspire agent init refresh, hook exec behavior, and ASPIRE_AGENT_TELEMETRY_MAX_PAYLOAD_CHARACTERS), pr_body_has_security_marker (Security considerations section), pr_label_breaking_change (breaking-change label + explicit Breaking changes section on OTLP MaxRequestSizeBytes default drop from 128 MiB to 64 MiB).
Documented in this draft:
src/frontend/src/content/docs/whats-new/aspire-13-6.mdx: new '#### Faster agent telemetry hook' subsection under CLI enhancements (native --hook exec instead of shell wrapper, unchanged wildcard coverage, aspire agent init refresh instructions, new env var), and a new '#### OpenTelemetry packages upgraded, smaller default OTLP request size' breaking-change subsection with the OtlpExporterOptions.MaxRequestSizeBytes workaround. Updated intro bullets and upgrade Aside to reference both changes.
src/frontend/src/content/docs/reference/cli/microsoft-collected-cli-telemetry.mdx: updated 'AI agent skill usage' section to describe the native-exec hook and the new max-payload environment variable.
Target branch resolution: candidate_source=pr_milestone (milestone 14.0) → candidate release/14.0 doesn't exist on aspire.dev; target_resolution=latest_release_fallback selected release/13.6, the latest available release branch.
David Pine (@IEvangelist) backporting to release/13.6 failed, the patch most likely resulted in conflicts. Please backport manually!
git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patchApplying: Reduce agent telemetry hook overhead without reducing coverageUsing index info to reconstruct a base tree...M eng/Versions.propsM src/Aspire.Cli/Agents/Hooks/TelemetryHookConfigurator.csM src/Aspire.Cli/Program.csM tests/Aspire.Cli.Tests/Agents/TelemetryHookScriptTests.csFalling back to patching base and 3-way merge...Auto-merging eng/Versions.propsAuto-merging src/Aspire.Cli/Agents/Hooks/TelemetryHookConfigurator.csAuto-merging src/Aspire.Cli/Program.csAuto-merging tests/Aspire.Cli.Tests/Agents/TelemetryHookScriptTests.csApplying: Use canonical telemetry catalog and configure hook payload limitsApplying: Align OpenTelemetry packages on releases older than seven daysApplying: Regenerate Seq configuration schema for OpenTelemetry 1.18Applying: Address agent telemetry review with command opt-in and manifest catalogUsing index info to reconstruct a base tree...M src/Aspire.Cli/Program.csM tests/Aspire.Cli.Tests/Utils/CliTestHelper.csFalling back to patching base and 3-way merge...Auto-merging src/Aspire.Cli/Program.csCONFLICT (content): Merge conflict in src/Aspire.Cli/Program.csAuto-merging tests/Aspire.Cli.Tests/Utils/CliTestHelper.cserror: Failed to merge in the changes.hint: Use 'git am --show-current-patch=diff' to see the failed patchhint: When you have resolved this problem, run "git am --continue".hint: If you prefer to skip this patch, run "git am --skip" instead.hint: To restore the original branch and stop patching, run "git am --abort".hint: Disable this message with "git config set advice.mergeConflict false"Patch failed at 0005 Address agent telemetry review with command opt-in and manifest catalogError: The process '/usr/bin/git' failed with exit code 128
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
area-clibreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.
4 participants
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.
Description
Preserves wildcard agent-hook coverage and all currently eligible Aspire telemetry while removing shell startup and synchronous upload waits.
AgentTelemetryCommandand normal command dispatch.InitializeTelemetryOnStartupdefaults to true; the agent command defers provider creation and enrichment until an eligible event exists. Existing first-run and generic invocation-span rules are preserved.skill-manifest.json, read in memory with the existing manifest types and source-generated serializer. The shipped inventory preserves all 7 skills and 33 references. MCP tool names still come from the embedded canonical hook because the manifest does not contain a tool inventory.IEnvironment; hook tests run in-process without changing global environment state. A documented setting bounds input before parsing.Fixes #20329
Closes #20042
Coordinated OpenTelemetry upgrade
The committed upgrade supersedes closed draft #20042 and consistently uses the newest releases published at least seven days before September 23, 2026:
The 1.19.x releases were too recent for that age requirement and are not the target. The GrpcNetClient approved-feed import succeeded in run 3085688, and full solution restore succeeded against configured feeds. No quarantine was bypassed. Existing Blazor playground-specific overrides from #20339 are unchanged. Seq's generated configuration schema was refreshed for the added OTLP properties.
Breaking changes
OpenTelemetry 1.18 reduces the default maximum serialized OTLP request from 128 MiB to 64 MiB. Oversized batches are dropped. Consumers relying on the previous limit can configure:
The default maximum OTLP response size is 4 MiB. Generated ServiceDefaults inherit updated versions; existing customer projects are not rewritten. Ordinary CLI shutdown behavior is explicitly preserved despite the Azure Monitor upgrade.
User-facing usage
After installing the updated CLI, refresh agent configuration:
Claude retains
matcher: "*"; Copilot retains unfilteredpostToolUse. Both directly executeaspire agent telemetry --hookwithout PowerShell/Bash. Compatibility scripts are taken unchanged from the canonical bundle.ASPIRE_AGENT_TELEMETRY_MAX_PAYLOAD_CHARACTERSconfigures the native input bound: default 65,536 UTF-16 characters, range 1–1,048,576. Oversized input is drained without retention; invalid values produce a diagnostic without breaking the agent.Validation
[OuterloopTest]; fast persistence and uploader-lifecycle coverage remains in regular CI. The real recovery scenario passed before this scheduling-only change.postToolUsewithexec/argsran its recorder after aviewcall.Security considerations
The hook processes bounded untrusted JSON and launches an independent uploader. Catalog inputs come from embedded release-verified resources, not mutable user-installed skills/scripts. Only manifest-listed
references/files are reference events; evals and scripts are excluded. No new listener, ingestion endpoint, raw-payload storage, or telemetry category is introduced. Direct argument vectors avoid shell interpretation. Existing exporter storage and process-isolation helpers are reused. Security review should cover classification parity, configuration ownership, and detached-process lifetime.Delivery remains subject to disk failures, exporter limits, retention, and permanent ingestion errors. Interrupted uploads may stay leased for several minutes; at-least-once delivery permits duplicates. Environment opt-out applies at process launch, not retroactively to running processes.
Checklist
<remarks />and<code />elements on your triple slash comments?