Skip to content

Improve crash telemetry: enums, FaultEvent, remove noise, dedup host detection#13289

Merged
YuliiaKovalova merged 9 commits intomainfrom
dev/crash-telemetry-improvements
Feb 24, 2026
Merged

Improve crash telemetry: enums, FaultEvent, remove noise, dedup host detection#13289
YuliiaKovalova merged 9 commits intomainfrom
dev/crash-telemetry-improvements

Conversation

@YuliiaKovalova
Copy link
Copy Markdown
Member

@YuliiaKovalova YuliiaKovalova commented Feb 24, 2026

Summary

Improves the crash telemetry infrastructure to produce higher-quality, more actionable data and enable Prism dashboard visibility ( continuation of #13270 based on the first results)

Changes

Convert ExitType and CrashOrigin from strings to enums

Remove noise from crash telemetry

  • Removed SwitchError and InitializationError from crash telemetry recording — these accounted for ~99.8% of crash events but represent expected user errors (bad CLI args, missing toolsets), not actual crashes

Remove redundant CrashTimestamp

  • The database ingestion timestamp already captures this; the client-side timestamp added no value

Deduplicate GetHostName()

  • Consolidated 3 copies of host-detection logic (VS / VSCode / MSBUILD_HOST_NAME) into a single BuildEnvironmentState.GetHostName() method

Harden DebugUtils static constructor

  • Wrapped in try/catch to prevent TypeInitializationException crashes when environment variable access fails

Copilot AI review requested due to automatic review settings February 24, 2026 16: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 refines MSBuild crash telemetry to make crash events more actionable and less noisy, while adding VS Prism visibility (via FaultEvent on .NET Framework) and consolidating host detection logic.

Changes:

  • Introduces typed crash classifications (CrashExitType, CrashOriginKind) and expands crash payload (origin + innermost exception type), while removing CrashTimestamp.
  • Adds best-effort Prism FaultEvent posting on .NET Framework and removes high-volume “expected error” crash telemetry cases.
  • Deduplicates host detection into BuildEnvironmentState.GetHostName() and hardens early debug-path initialization.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Shared/ExceptionHandling.cs Switches unhandled-exception crash recording to typed CrashExitType.
src/Shared/Debugging/DebugUtils.cs Wraps debug-path initialization in try/catch to avoid type initialization failures.
src/MSBuild/XMake.cs Stops recording crash telemetry for expected CLI/toolset failures; converts exit types to CrashExitType; uses shared host detection.
src/Framework/Telemetry/CrashTelemetryRecorder.cs Updates APIs to use enums; adds .NET Framework FaultEvent posting.
src/Framework/Telemetry/CrashTelemetry.cs Adds enums and new crash fields (origin, origin “assembly” namespace, innermost exception type); updates property emission.
src/Framework/BuildEnvironmentState.cs Adds centralized host detection (GetHostName).
src/Framework.UnitTests/CrashTelemetry_Tests.cs Updates tests for enums and new fields; removes timestamp assertions; adds new test coverage for origin/innermost exception.
src/Build/BackEnd/BuildManager/BuildManager.cs Uses BuildEnvironmentState.GetHostName() and typed CrashExitType for end-build crash telemetry.

Copy link
Copy Markdown
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

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

looks good, i'd like to see exp insertion so we can merge confidently and derisk from "merge, breaks vs, revert, adjust"

- Include full stack trace in error messages (DebugUtils, XMake) instead of just ex.Message
- Rename CrashOriginAssembly to CrashOriginNamespace for clarity
- Rewrite ExtractOriginNamespace to use index-based parsing (avoids Split/Substring allocations)
- Fix ClassifyOrigin prefix check: match 'Microsoft.Build' as exact or dot-boundary prefix
- Conditionally apply NoInlining to PostFaultEvent only on .NET Framework (inlines to empty on Core)
- Add FaultEvent documentation link to PostFaultEvent
- Add comment explaining .NET Core memory stats via GC.GetGCMemoryInfo

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YuliiaKovalova YuliiaKovalova enabled auto-merge (squash) February 24, 2026 18:45
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
@YuliiaKovalova YuliiaKovalova merged commit a2c1035 into main Feb 24, 2026
10 checks passed
@YuliiaKovalova YuliiaKovalova deleted the dev/crash-telemetry-improvements branch February 24, 2026 21:41
JanProvaznik pushed a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
…detection (dotnet#13289)

## Summary

Improves the crash telemetry infrastructure to produce higher-quality,
more actionable data and enable Prism dashboard visibility (
continuation of dotnet#13270 based on
the first results)

## Changes

### Convert ExitType and CrashOrigin from strings to enums

### Remove noise from crash telemetry
- Removed `SwitchError` and `InitializationError` from crash telemetry
recording — these accounted for ~99.8% of crash events but represent
expected user errors (bad CLI args, missing toolsets), not actual
crashes

### Remove redundant `CrashTimestamp`
- The database ingestion timestamp already captures this; the
client-side timestamp added no value

###  Deduplicate `GetHostName()`
- Consolidated 3 copies of host-detection logic (VS / VSCode /
`MSBUILD_HOST_NAME`) into a single `BuildEnvironmentState.GetHostName()`
method

### Harden `DebugUtils` static constructor
- Wrapped in try/catch to prevent `TypeInitializationException` crashes
when environment variable access fails

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

5 participants