Add telemetry activity for running app host in CLI#16346
Conversation
Show shortened trace ID as a dashboard hyperlink in the trace detail header instead of the full trace ID as plain text. Hoists the link computation so it is shared between the empty-trace and normal paths.
Add a reported telemetry activity to RunCommand that records: - App host language (csharp, typescript, etc.) - Whether the run is detached or isolated - error.type with friendly names for known failure modes Also add ASPIRE_CLI_RUN_DETACHED env var so the detached child process can report its mode accurately via telemetry. Includes a parameterized test covering all combinations of detached and isolated modes.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16346Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16346" |
There was a problem hiding this comment.
Pull request overview
Adds a new reported telemetry activity around CLI AppHost runs so telemetry backend can track run attempts, mode (detached/isolated), language, and categorized failure reasons.
Changes:
- Introduces
aspire/cli/run_apphostreported activity with new AppHost-related tags (language, detached, isolated, error.type). - Plumbs detached-mode detection into the child process via
ASPIRE_CLI_RUN_DETACHEDand reads it fromIConfigurationinRunCommand. - Adds a parameterized unit test covering the detached/isolated combinations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs | Adds a theory validating the new reported activity and tags. |
| src/Shared/KnownConfigNames.cs | Adds ASPIRE_CLI_RUN_DETACHED config/environment variable name constant. |
| src/Aspire.Cli/Telemetry/TelemetryConstants.cs | Adds new tags and the aspire/cli/run_apphost activity name. |
| src/Aspire.Cli/Commands/TelemetryTracesCommand.cs | Minor UX tweak to use a shortened trace id in the “Trace:” header. |
| src/Aspire.Cli/Commands/RunCommand.cs | Starts the reported activity and populates tags / error.type on failure paths. |
| src/Aspire.Cli/Commands/AppHostLauncher.cs | Sets/clears detached env var around spawning the detached child process. |
…cess - Start runActivity before project discovery so all failure paths are captured - Set error.type on early-return project_not_found and canceled paths - Pass ASPIRE_CLI_RUN_DETACHED via DetachedProcessLauncher additionalEnvironmentVariables instead of mutating parent process global state - Add IReadOnlyDictionary<string, string>? additionalEnvironmentVariables parameter to DetachedProcessLauncher.Start
This reverts commit 24c96e3.
|
🎬 CLI E2E Test Recordings — 72 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #24699171752 |
|
No documentation PR is required for this change. This PR adds internal telemetry instrumentation (
|
Description
Add a reported telemetry activity (
aspire/cli/run_apphost) toRunCommandthat tracks app host runs with the following tags:aspire.cli.apphost.language– the app host language (e.g. CSharp, TypeScript). Only set when the project is successfully resolved.aspire.cli.apphost.detached– whether the run is in detached modeaspire.cli.apphost.isolated– whether the run is in isolated modeerror.type– friendly error category for known failure modes (project_not_found,build_failed,incompatible_version,certificate_trust_failed,backchannel_connection_failed,dashboard_failed,canceled), or the exception type for unexpected errors. Absence of this tag indicates success.The activity is started early (before project discovery) so that all failure paths are captured in telemetry.
The activity uses
StartReportedActivityso it is exported to the telemetry backend.To support detached mode telemetry, the
ASPIRE_CLI_RUN_DETACHEDenvironment variable is passed to the child process viaDetachedProcessLauncher.Start'sadditionalEnvironmentVariablesparameter (no parent-process mutation), and read fromIConfigurationinRunCommand.DetachedProcessLauncher.Startgains an optionaladditionalEnvironmentVariablesdictionary parameter that is applied to the child process environment on both Windows (via the custom environment block) and Unix (viaProcessStartInfo.Environment).Includes a parameterized test (
Theory) covering all 4 combinations of(detached, isolated).Checklist