Add CLI telemetry export#13963
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13963Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13963" |
6fc7a90 to
6b6e7b5
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds telemetry export functionality to the Aspire CLI. The implementation includes OpenTelemetry instrumentation with Azure Monitor and OTLP exporters, platform-specific machine information providers for device identification, and comprehensive error tracking throughout CLI commands.
Changes:
- Introduces telemetry infrastructure with dual activity sources (reported and diagnostics)
- Adds machine information providers for Windows, Linux, and macOS to generate persistent device IDs
- Integrates telemetry error recording into all command exception handlers
- Updates test infrastructure to support initialized telemetry instances
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Cli/Telemetry/AspireCliTelemetry.cs | Core telemetry service with activity creation and error recording |
| src/Aspire.Cli/Telemetry/TelemetryManager.cs | Manages TracerProvider instances for Azure Monitor and debug exporters |
| src/Aspire.Cli/Telemetry/TelemetryConstants.cs | Defines telemetry tag and event name constants |
| src/Aspire.Cli/Telemetry/*MachineInformationProvider.cs | Platform-specific device ID and MAC address collection |
| src/Aspire.Cli/Program.cs | Initializes telemetry, adds main activity tracking, and custom exception handling |
| src/Aspire.Cli/Commands/*.cs | Integrates telemetry into all commands with error recording |
| src/Shared/IConfigurationExtensions.cs | Adds CLI conditional compilation and simplifies string retrieval |
| tests/Aspire.Cli.Tests/Telemetry/*.cs | Comprehensive test coverage for telemetry components |
| tests/Aspire.Cli.Tests/*Tests.cs | Updates existing tests to use initialized telemetry |
| Directory.Packages.props, eng/Versions.props | Adds Azure Monitor and Console exporter package references |
| eng/clipack/Common.projitems | Increases max file size from 25MB to 30MB |
f519163 to
d6ff61c
Compare
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #21388741305 |
|
Is that related to #13727 ? |
|
No. The is telemetry about what the CLI is doing |
e6a28fd to
578dc31
Compare
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #21269135037 |
578dc31 to
3b0b68e
Compare
6c1b42d to
7c6df61
Compare
| await app.StartAsync().ConfigureAwait(false); | ||
|
|
||
| // Display first run experience if this is the first time the CLI is run on this machine | ||
| var noLogo = args.Any(a => a == "--nologo"); |
There was a problem hiding this comment.
@JamesNK we should support an env var for this too, e.g. ASPIRE_CLI_NOLOGO. We can add that in a follow up.
|
@JamesNK would be great to get an E2E CLI test added that shows the welcome banner so we can see it in asciinema recordings (again, can do in follow up). |
Add missing AspireCliTelemetry parameter to ResourcesCommand and LogsCommand constructors, and pass it to the BaseCommand base constructor. This fixes the build failures introduced by PR #13963 which added telemetry support to BaseCommand. Co-authored-by: radical <1472+radical@users.noreply.github.com>
* Initial plan * Fix missing telemetry parameter in ResourcesCommand and LogsCommand Add missing AspireCliTelemetry parameter to ResourcesCommand and LogsCommand constructors, and pass it to the BaseCommand base constructor. This fixes the build failures introduced by PR #13963 which added telemetry support to BaseCommand. Co-authored-by: radical <1472+radical@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: radical <1472+radical@users.noreply.github.com>
Description
This PR enables CLI telemetry export to AppInsights. High level changes:
ASPIRE_CLI_TELEMETRY_OPTOUTenv var.ASPIRE_CLI_CONSOLE_EXPORTER_LEVEL=Reportedto see what is exported.--nologooption.Remaining tasks:
Addresses #14034
Example console output (displaying first run text and with console exporter enabled):
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate