Skip to content

feat: add WIL-based TraceLogging ETW telemetry (experimental)#493

Open
RamonArjona4 wants to merge 1 commit into
mainfrom
user/ramonarjona4/tracelogging
Open

feat: add WIL-based TraceLogging ETW telemetry (experimental)#493
RamonArjona4 wants to merge 1 commit into
mainfrom
user/ramonarjona4/tracelogging

Conversation

@RamonArjona4

@RamonArjona4 RamonArjona4 commented Jun 4, 2026

Copy link
Copy Markdown
Member

📖 Description

Add experimental telemetry support using the tracelogging crate for
pure Rust ETW event emission. No C++ shim or WIL dependency required.

  • New mxc_telemetry crate with define_provider! and write_event! for
    MXC.Execution and MXC.Error events using COMMON_MXC_PARAMS struct fields
  • build.rs generates provider_def.rs with optional group_id based on
    MXC_TELEMETRY_PROVIDER_GROUP_GUID env var for internal builds
  • wxc_common::telemetry module: config resolution, sanitize_error_message()
    (strips Windows paths, Unix paths, UNC paths, and URL credentials), event types
    with bounded FailureReason enum
  • Schema, config parser, and SDK types extended with telemetry.enabled field
  • Telemetry callsites in wxc and lxc binaries emit execution and error events
  • Experimental feature: requires --experimental flag and telemetry.enabled
    in the JSON config
  • Non-Windows: all telemetry functions compile as no-ops
  • Design doc at docs/telemetry-wil-integration.md with architecture,
    feature comparison table, and GUID override mechanism

Build integration (pipeline GUID substitution, license override script)
will follow in a separate PR.

🔗 References

#492

🔍 Validation

Built locally and ran unit tests. Validated that ETW events fire when build configuration is not set to allow telemetry.
Validated that telemetry appears as expected in the UTC when telemetry provider is correctly enabled.

✅ Checklist

📋 Issue Type

  • Bug fix
  • [ x] Feature
  • Task

Microsoft reviewers: PR builds don't auto-run (ADO policy). Comment /azp run
to start MXC-PR-Build. See docs/pull-requests.md.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings June 4, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::telemetry module and wires telemetry init/emit/shutdown into wxc-exec and lxc-exec behind --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.

Comment thread tests/examples/28_telemetry_enabled.json Outdated
Comment thread src/mxc_wil_telemetry/build.rs Outdated
Comment thread src/mxc_wil_telemetry/build.rs Outdated
Comment thread src/core/wxc_common/src/telemetry/events.rs Outdated
Comment thread src/core/wxc_common/src/models.rs
Comment thread .azure-pipelines/templates/Rust.Build.Job.yml Outdated
Comment thread .azure-pipelines/templates/Rust.Build.Job.yml Outdated
Comment thread docs/telemetry-wil-integration.md Outdated
Comment thread docs/telemetry-wil-integration.md Outdated
Comment thread docs/telemetry-wil-integration.md Outdated
Comment thread src/mxc_wil_telemetry/shim/mxc_telemetry_shim.cpp Outdated
Comment thread tests/examples/28_telemetry_enabled.json Outdated
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Issue needs attention from issue or PR author label Jun 5, 2026
@MGudgin

MGudgin commented Jun 8, 2026

Copy link
Copy Markdown
Member

@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from 2e88af1 to 89a7d69 Compare June 9, 2026 19:29
@RamonArjona4 RamonArjona4 requested a review from Copilot June 9, 2026 19:44
@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Attention Issue needs attention from Microsoft and removed Needs-Author-Feedback Issue needs attention from issue or PR author labels Jun 9, 2026
Comment thread docs/telemetry-wil-integration.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread tests/scripts/run_telemetry_etw_smoke_test.ps1 Outdated
Comment thread tests/scripts/run_telemetry_build_override_test.ps1 Outdated
Comment thread src/mxc_wil_telemetry/Cargo.toml Outdated
Comment thread src/core/wxc_common/src/telemetry/events.rs Outdated
Comment thread .azure-pipelines/templates/Rust.Build.Job.yml Outdated
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch 7 times, most recently from d348769 to d6eccb0 Compare June 9, 2026 23:12
@RamonArjona4 RamonArjona4 requested a review from Copilot June 9, 2026 23:23
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from d6eccb0 to 5edf9ed Compare June 9, 2026 23:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread tests/examples/28_telemetry_enabled.json
Comment thread tests/scripts/run_telemetry_etw_smoke_test.ps1 Outdated
Comment thread src/mxc_telemetry/build.rs Outdated
Comment thread docs/schema.md
Comment thread docs/telemetry-wil-integration.md Outdated
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from 5edf9ed to 27c74b9 Compare June 9, 2026 23:55
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch 2 times, most recently from 2a8e935 to 73562f3 Compare June 16, 2026 02:49
@RamonArjona4 RamonArjona4 requested a review from Copilot June 16, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Not ready to approve

There are correctness/privacy issues to address (invalid $schema reference in the new telemetry example and incomplete Unix path sanitization that can leak /Users/<name> into telemetry).

Copilot's findings
  • Files reviewed: 22/24 changed files
  • Comments generated: 8

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread tests/examples/28_telemetry_enabled.json Outdated
Comment thread src/core/wxc_common/src/telemetry/events.rs Outdated

/// Unregister the TraceLogging ETW provider.
///
/// Must be called before process exit if `init()` returned `true`.
Comment thread sdk/src/types.ts
Comment thread build-with-telemetry.local.ps1 Outdated
Comment thread README.md Outdated
Comment thread tests/scripts/run_telemetry_etw_smoke_test.ps1 Outdated
Comment thread tests/scripts/run_telemetry_etw_smoke_test.ps1 Outdated
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch 4 times, most recently from 19e2297 to 81dc63f Compare June 16, 2026 03:25
@RamonArjona4 RamonArjona4 requested a review from Copilot June 16, 2026 03:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Not ready to approve

A few correctness/robustness issues were found in telemetry sanitization and failure classification that can lead to misleading or malformed telemetry output.

Copilot's findings
  • Files reviewed: 21/22 changed files
  • Comments generated: 6

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment thread src/core/wxc_common/src/telemetry/events.rs
Comment thread src/core/wxc/src/main.rs
Comment thread src/core/wxc/src/main.rs
Comment thread src/core/lxc/src/main.rs
Comment thread src/core/lxc/src/main.rs
Comment thread src/core/wxc_common/src/telemetry/mod.rs
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from 87339b9 to 81dc63f Compare June 16, 2026 03:47
@RamonArjona4 RamonArjona4 marked this pull request as ready for review June 16, 2026 17:36
@RamonArjona4 RamonArjona4 requested a review from a team as a code owner June 16, 2026 17:36
@RamonArjona4 RamonArjona4 requested a review from bbonaby June 16, 2026 17:36
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from 81dc63f to 39559fd Compare June 17, 2026 21:38
@RamonArjona4 RamonArjona4 removed the Needs-Attention Issue needs attention from Microsoft label Jun 17, 2026
Add pure Rust TraceLogging ETW telemetry for MXC using the tracelogging
crate. No C++ shim, WIL, or FFI required.

- New mxc_telemetry crate with build.rs-generated provider definition
- MXC.Execution and MXC.Error events with MICROSOFT_KEYWORD_MEASURES
- Common event fields (Version, Channel, IsDebugging, UTCReplace_AppSessionGuid)
- PII sanitization for error messages (path stripping, URL credential removal)
- Optional provider group GUID via MXC_TELEMETRY_PROVIDER_GROUP_GUID env var
- Telemetry gated behind experimental.telemetry.enabled config + --experimental flag
- Cross-platform: full ETW on Windows, no-op stubs on Linux/macOS
- ETW smoke test script and example config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RamonArjona4 RamonArjona4 force-pushed the user/ramonarjona4/tracelogging branch from 39559fd to b6e02db Compare June 17, 2026 21:44
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.

4 participants