Add telemetry for --help, --version, and --info options - #55442
Merged
Conversation
- When a root-level option (--help/--version/--info) is invoked, set verb to the option name instead of empty string so these invocations are visible in telemetry. - Add a 'help=true' property whenever PrintHelpAction fires on any command (e.g. 'dotnet build --help'), allowing distinction between actual command runs and help requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
baronfel
reviewed
Jul 23, 2026
baronfel
left a comment
Member
There was a problem hiding this comment.
Excellent, cross-cutting change 👍
baronfel
approved these changes
Jul 23, 2026
baronfel
enabled auto-merge (squash)
July 23, 2026 22:10
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves .NET CLI telemetry classification for terminating help/version/info flows by (1) ensuring root-level option invocations (e.g., dotnet --help) produce a non-empty verb and (2) adding a help=true property to distinguish dotnet <verb> --help from actual command executions.
Changes:
- Update
TelemetryFilter.FilterImplto synthesize a verb for terminating root-level option actions when no subcommand is present. - Add a
help=truetelemetry property when the active action isPrintHelpAction(including the AOT-derived action). - Add MSTest coverage for root
--help/--version/--infoand subcommand--helpscenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Cli/dotnet/Telemetry/TelemetryFilter.cs | Adds logic to derive a telemetry verb for terminating root options and adds a help property for help actions. |
| test/dotnet.Tests/TelemetryTests/TelemetryFilterTest.cs | Adds tests covering the new verb behavior for root options and the new help property behavior for help requests. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
The CLI collects telemetry for command invocations, but
--help,--version, and--infohave a gap: root-level invocations likedotnet --helpproduce an empty verb, making them invisible in telemetry. Subcommand help likedotnet build --helpemits telemetry withverb=buildbut is indistinguishable from an actualdotnet buildexecution. This PR closes both gaps.Changes
Modifies
TelemetryFilter.FilterImplwith two small additions:Meaningful verb for root-level options -- When
RootSubCommandResult()returns an empty string and the active action is a terminating option (--help,--version,--info), the option's name is used as the verb instead of empty string.help=trueproperty for help requests -- WhenparseResult.Actionis aPrintHelpAction(covers both managed and AOT paths), ahelp=trueproperty is added to the telemetry event. This distinguishesdotnet build --helpfromdotnet build.Resulting telemetry
dotnet --help--helptruedotnet --version--versiondotnet --info--infodotnet build --helpbuildtruedotnet buildbuildPerformance
Benchmarked with 10-15 iterations per command. The telemetry infrastructure cost (~300ms for OpenTelemetry/TelemetryClient init) is pre-existing and unchanged. Our filter additions are just two type checks and one dictionary insert -- nanosecond-scale operations.
TrackEventdispatches viaTask.Run()(fire-and-forget), so event emission does not block command execution.--version--helpbuild --helpNo measurable regression.
Testing
Added 5 new tests in
TelemetryFilterTest.cscovering all new scenarios. All 12 telemetry filter tests pass.