Skip to content

Forward MSBuild build/tasks/details telemetry event#54092

Open
jankratochvilcz wants to merge 1 commit into
mainfrom
jan/msbuild-telemetry-event-detais
Open

Forward MSBuild build/tasks/details telemetry event#54092
jankratochvilcz wants to merge 1 commit into
mainfrom
jan/msbuild-telemetry-event-detais

Conversation

@jankratochvilcz
Copy link
Copy Markdown
Contributor

@jankratochvilcz jankratochvilcz commented Apr 27, 2026

Context

Companion to dotnet/msbuild#13609, which adds a new per-task telemetry event build/tasks/details emitted from BuildManager. The MSBuild PR motivates this work: we want richer task-execution data (per-task name, executions count, task host runtime, etc.) so we can use real-world frequency data to drive decisions about which built-in tasks to prioritize / optimize.

The event carries:

  • TaskCount — number of distinct tasks in the payload (capped at 100).
  • TotalTaskCount — total number of distinct tasks observed.
  • Tasks — JSON array of task-detail records (top 100 by ExecutionsCount), ready for Kusto mv-expand.

Changes

src/Cli/dotnet/Commands/MSBuild/MSBuildLogger.cs:

  • Added TasksDetailsTelemetryEventName = "build/tasks/details" constant.
  • Added a case in FormatAndSend that pass-through-forwards the event under the msbuild/ namespace, with no hashed properties (the payload is already a JSON string with no PII).

Unlike the existing build/tasks / build/tasks/taskfactory events, this event is not aggregated client-side — MSBuild already does the aggregation/capping (top 100, hashed custom-task names) and the SDK just relays it.

Testing

  • New test ItForwardsTaskDetailsEvent in GivenMSBuildLogger verifies the event is forwarded under the expected name and that all three properties (Tasks, TaskCount, TotalTaskCount) are preserved verbatim.
  • All 8 GivenMSBuildLogger tests pass locally.

Rollout

This change is forward-compatible: older MSBuilds simply won't emit the event, and the case in FormatAndSend is a no-op when the event isn't raised. No env-var gating is needed on the SDK side — gating lives in MSBuild (MSBUILDTELEMETRYEXCLUDETASKSDETAILS / Traits.ExcludeTasksDetailsFromTelemetry).

@jankratochvilcz jankratochvilcz force-pushed the jan/msbuild-telemetry-event-detais branch from 4da8540 to a47927f Compare April 27, 2026 11:39
@jankratochvilcz jankratochvilcz changed the title Jan/msbuild telemetry event detais Forward MSBuild build/tasks/details telemetry event May 25, 2026
@jankratochvilcz jankratochvilcz marked this pull request as ready for review May 25, 2026 15:10
Copilot AI review requested due to automatic review settings May 25, 2026 15:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the .NET SDK’s MSBuild logger to forward a new MSBuild telemetry event (build/tasks/details) under the msbuild/ namespace, enabling richer per-task execution telemetry to flow through the CLI telemetry pipeline.

Changes:

  • Add TasksDetailsTelemetryEventName = "build/tasks/details" and forward it via MSBuildLogger.FormatAndSend as msbuild/build/tasks/details without hashing.
  • Add a new unit test verifying the event name and that Tasks, TaskCount, and TotalTaskCount are preserved verbatim.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Cli/dotnet/Commands/MSBuild/MSBuildLogger.cs Adds a constant and a FormatAndSend switch case to forward build/tasks/details as msbuild/build/tasks/details.
test/dotnet.Tests/CommandTests/MSBuild/GivenMSBuildLogger.cs Adds a test validating forwarding behavior and property preservation for the new telemetry event.

}

[Fact]
public void ItForwardsTaskDetailsEvent()
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.

2 participants