feat: add WIL-based TraceLogging ETW telemetry (experimental)#493
feat: add WIL-based TraceLogging ETW telemetry (experimental)#493RamonArjona4 wants to merge 6 commits into
Conversation
Implements WIL-based TraceLogging ETW telemetry for MXC following the WinAppSDK pattern exactly: - New mxc_wil_telemetry crate: C++ shim using WIL TraceLoggingProvider with SRWLOCK-protected state, Part B common fields, and flat extern C FFI surface for safe Rust wrappers - WIL headers downloaded from NuGet at build time (header-only, MIT) - Private GUID substitution via MXC_TELEMETRY_CONFIG_OVERRIDE env var, mirroring WinAppSDK's UpdateTraceloggingConfig pipeline step - Pipeline integration: NuGet auth, restore, env var injection in Rust.Build.Job.yml (no continueOnError, matching WinAppSDK) - Deterministic NuGet restore via scoped nuget.config with <clear/> - Sticky cache prevention: .public backup/restore of traceloggingconfig.h - Events: MXC.Execution and MXC.Error with sanitized error messages - FailurePhase-aware failure classification (InitError vs ProcessError) - Telemetry gated behind experimental.telemetry.enabled config flag - Comprehensive test suite: 12 FFI unit tests, E2E tests, build override validation script, ETW capture smoke test - Architecture documentation in docs/telemetry-wil-integration.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an experimental TraceLogging ETW telemetry pipeline to MXC, including a WIL-based C++ shim with Rust wrappers, config/schema plumbing (experimental.telemetry.enabled), internal-build GUID/license override hooks, and validation scripts/tests/docs.
Changes:
- Introduces
mxc_wil_telemetry(build-time WIL header acquisition + C++ TraceLogging provider shim + Rust FFI wrappers). - Adds
wxc_common::telemetrymodule and wires telemetry init/emit/shutdown intowxc-execandlxc-execbehind--experimental+ config flag. - Adds schema/docs/examples/tests and ADO pipeline steps for internal GUID substitution + SDK license override.
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scripts/run_telemetry_etw_smoke_test.ps1 | Adds an admin-required ETW capture smoke test script for the public provider GUID. |
| tests/scripts/run_telemetry_build_override_test.ps1 | Adds a validation script for MXC_TELEMETRY_CONFIG_OVERRIDE build behavior. |
| tests/examples/28_telemetry_enabled.json | Adds an example config enabling experimental telemetry. |
| src/testing/wxc_e2e_tests/tests/e2e_windows.rs | Adds ignored Windows E2E tests for telemetry enabled/disabled paths. |
| src/testing/wxc_e2e_tests/src/lib.rs | Adds run_wxc_example() helper for running configs from tests/examples/. |
| src/mxc_wil_telemetry/src/lib.rs | Implements Rust-safe wrappers around the C++ telemetry shim (no-op on non-Windows). |
| src/mxc_wil_telemetry/shim/mxc_telemetry_shim.h | Declares the extern “C” surface for Rust FFI. |
| src/mxc_wil_telemetry/shim/mxc_telemetry_shim.cpp | Implements WIL TraceLogging provider + Part B fields + event emission. |
| src/mxc_wil_telemetry/Cargo.toml | Adds the new crate with build dependencies for download/extract/compile. |
| src/mxc_wil_telemetry/build.rs | Downloads/extracts WIL headers, applies override, compiles shim (Windows-only). |
| src/core/wxc/src/main.rs | Initializes telemetry from config and emits execution/error events on completion. |
| src/core/wxc_common/src/telemetry/mod.rs | Adds telemetry module entrypoint: enablement logic + init/shutdown. |
| src/core/wxc_common/src/telemetry/events.rs | Defines telemetry event types, sanitization, and emit wrappers. |
| src/core/wxc_common/src/models.rs | Adds experimental.telemetry config model (TelemetryConfig). |
| src/core/wxc_common/src/lib.rs | Exposes telemetry module from wxc_common. |
| src/core/wxc_common/src/config_parser.rs | Parses experimental.telemetry.enabled into TelemetryConfig + tests. |
| src/core/wxc_common/Cargo.toml | Links wxc_common against the new mxc_wil_telemetry crate. |
| src/core/lxc/src/main.rs | Mirrors telemetry init/emit wiring for the Linux executor (no-op behavior). |
| src/Cargo.toml | Adds mxc_wil_telemetry to the Rust workspace + workspace deps. |
| src/Cargo.lock | Updates lockfile for new crate + added build dependencies. |
| sdk/src/types.ts | Adds TypeScript TelemetryConfig and experimental.telemetry typing. |
| scripts/apply-license-override.ps1 | Adds script for internal license override injection/restoration. |
| schemas/dev/mxc-config.schema.0.7.0-dev.json | Extends dev schema with experimental.telemetry.enabled. |
| README.md | Documents experimental telemetry behavior and adds doc link. |
| docs/telemetry-wil-integration.md | Adds detailed architecture and internal-build override documentation. |
| docs/schema.md | Updates schema docs to include experimental.telemetry. |
| build/telemetry/packages.config | Adds private NuGet package manifest for internal telemetry group GUID header. |
| build/telemetry/nuget.config | Adds scoped nuget.config with <clear/> for deterministic internal restore. |
| .gitignore | Ignores restored private telemetry package artifacts and license backup. |
| .azure-pipelines/templates/Rust.Build.Job.yml | Adds official-build steps for internal NuGet restore + env var injection + license override. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| - task: NuGetAuthenticate@1 | ||
| displayName: 'NuGet authenticate for telemetry config' | ||
| inputs: | ||
| nuGetServiceConnections: 'TelemetryInternal' |
There was a problem hiding this comment.
issue: so this pipeline is run in the Dart ADO project https://microsoft.visualstudio.com/Dart/_build?definitionId=190018. In there I don't see a service connection for TelemetryInternal so I don't think this would work. That said, we should talk about what you want to do in the pipeline offline as there might be a simpler way to do this.
FYI we have our own nuget feed in there as well https://microsoft.visualstudio.com/Dart/_artifacts/feed/Mxc-Azure-Feed where we can add internal packages which can be retrieved during build time.
| condition: and(succeeded(), eq('${{ item.os }}', 'windows')) | ||
|
|
||
| # --- SDK license override (mirrors telemetry GUID substitution) --- | ||
| # For internal npm publishes, the public MIT-only LICENSE.md is replaced |
There was a problem hiding this comment.
question: "internal npm publishes" what do you mean by this? We only publish to the public npm repository. See my comment above about chatting about what you want to see happen in the pipelines/release package. It's probably better to handle this part in a follow up PR.
| ┌──────────────────────────────────────────────────────┐ | ||
| │ C++ shim (mxc_telemetry_shim.cpp) │ | ||
| │ Compiled by cc crate in build.rs │ | ||
| │ │ | ||
| │ MxcTelemetryProvider : wil::TraceLoggingProvider │ | ||
| │ ├── IMPLEMENT_TRACELOGGING_CLASS(...) │ | ||
| │ ├── TraceLoggingOptionMicrosoftTelemetry() │ | ||
| │ └── _MXC_GENERIC_PARTB_FIELDS on every event │ | ||
| │ ├── Version │ | ||
| │ ├── Channel ("dev" / "release") │ | ||
| │ ├── IsDebugging │ | ||
| │ └── UTCReplace_AppSessionGuid = true │ | ||
| └───────────────┬──────────────────────────────────────┘ | ||
| │ Links against WIL headers (header-only) | ||
| ▼ | ||
| ┌──────────────────────────────────────────────────────┐ | ||
| │ WIL (Microsoft.Windows.ImplementationLibrary) │ | ||
| │ Downloaded from NuGet at build time │ | ||
| │ MIT licensed, header-only │ | ||
| │ Version: 1.0.260126.7 │ | ||
| └──────────────────────────────────────────────────────┘ |
There was a problem hiding this comment.
issue: Is there a reason you moved away form using the traceloggigng and now using cpp shims? does WIL have something very specific that the rust crate doesn't have?
| This follows the WinAppSDK pattern described in the WinAppSDK Telemetry | ||
| spec (per guidance from Mythilli Srinivasan). |
There was a problem hiding this comment.
issue: can remove since this is the integration guide
| 2. scripts/apply-license-override.ps1 runs: | ||
| ├── MXC_LICENSE_OVERRIDE is set: | ||
| │ ├── Back up sdk/LICENSE.md → sdk/LICENSE.md.public | ||
| │ └── Copy private EULA over sdk/LICENSE.md |
There was a problem hiding this comment.
issue: we need the license to stay MIT in the npm package, unless you spoke to CELA about this?
| @@ -0,0 +1,185 @@ | |||
| // Copyright (c) Microsoft Corporation. | |||
There was a problem hiding this comment.
issue: see questions above. I still don't see why we can't use the tracelogging crate for this.
| @@ -0,0 +1,10 @@ | |||
| { | |||
| "$schema": "../../schemas/dev/mxc-config.schema.0.7.0-dev.json", | |||
There was a problem hiding this comment.
issue: bad character at the end by the looks of it
Implements WIL-based TraceLogging ETW telemetry for MXC following the WinAppSDK pattern exactly:
📖 Description
This PR will add Tracelogging to the released npm package of mxc for Windows. Tracelogging on Linux or Mac systems is a no-op. Tracelogging is limited to simple usage and failure details of the MXC executable as built and distributed through npm.
🔗 References
#492
🔍 Validation
Built locally and ran unit tests
✅ Checklist
📋 Issue Type
Microsoft reviewers: PR builds don't auto-run (ADO policy). Comment
/azp runto start
MXC-PR-Build. See docs/pull-requests.md.Microsoft Reviewers: Open in CodeFlow