Repository navigation
feat: add TraceLogging ETW telemetry (experimental) - #493
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
2e88af1 to
89a7d69
Compare
d348769 to
d6eccb0
Compare
d6eccb0 to
5edf9ed
Compare
5edf9ed to
27c74b9
Compare
| tracelogging::write_event!( | ||
| MXC_PROVIDER, | ||
| "MXC.Error", | ||
| level(Warning), |
There was a problem hiding this comment.
This is an error even type but logged in as warning. Are there any critical events that need to be ALWAYS logged in MXC (e.g., crashes)? If yes, you should log them accordingly.
There was a problem hiding this comment.
Added a comment around the intention behind the levels we're choosing. The name "Error" here is admittedly non-descript and is meant as an indication of infrastructure failure distinct from workload exit status.
A couple of things that will need to be captured in future work:
- We'll need to have a future PR to capture the lifecycle of IsolationSession.
- We'll need to install std::panic::hook to capture MXC panics in telemetry.
| | Provider name `"Microsoft.MXC"` | ✅ | Standard ETW naming | | ||
| | Provider GUID `{7f10def4-a258-5fea-510e-2c3bb976687f}` | ✅ | Derived from the name; identifies the provider, harmless | | ||
| | `build.rs` env var mechanism | ✅ | Mechanism is public | | ||
| | `MXC_TELEMETRY_PROVIDER_GROUP_GUID` env var name | ✅ | Key is public; value is private | |
There was a problem hiding this comment.
I just set this up as a pipeline variable for our official pipeline here you should be able to click the variables button at the top right and see/confirm the guid I added.
Based on what you have in your build.rs below I believe this should actually work out the box as that environment variable should be visible to cargo at build time. I'll send you a link to the sharepoint which will show you how you can run an official build manually using this local branch.
|
I am not convinced MXC, at this point, needs telemetry. With MXC in alpha + the low number of users + an even lower number of events that are sent to Microsoft, the amount of useful events will be super slim. I do not believe any useful decisions can be made from the small number of events sent to Microsoft. |
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 <[email protected]>
Address open PR review feedback on the MXC.Error telemetry event: - Data minimization (PII): MXC.Error no longer emits the free-form error message. The event now carries only the bounded `error_type` category and the numeric `exit_code`, so paths, usernames, and credentials cannot leak through telemetry. Removes the best-effort `sanitize_error_message()` char-walker (and its tests) entirely, closing the class of sanitizer gaps. - De-duplication (MGudgin): hoist the ~55-line telemetry emit block that was duplicated verbatim in `wxc` and `lxc` into a single shared `wxc_common::telemetry::emit_completion()`; both binaries now call it. - Docs: reconcile README and the telemetry doc with the stronger guarantee (no free-form error text emitted; only category + exit code). Co-authored-by: Copilot <[email protected]>
The doc describes the pure-Rust TraceLogging architecture; the old "wil-integration" filename was a stale leftover from the WIL C++ shim design that was removed during the pivot. Update the README link too. Co-authored-by: Copilot <[email protected]>
… and address review #493 Addresses Tiers 1-3 + items 8-9 of the PR #493 adversarial review: - build.rs: gate MXC_TELEMETRY_PROVIDER_GROUP_GUID validation on Windows targets only so a stray/malformed env var can't break cross-platform builds; extract pure code-gen into provider_codegen.rs and unit-test it. - mxc_telemetry Cargo.toml: inherit tracelogging from [workspace.dependencies] (pinned 1.2) instead of a crate-local '1'. - telemetry/mod.rs: use ContainmentBackend::wire_name() instead of a duplicated backend_name() map; add emit_early_exit() and a classify_failure mapping unit test. - mxc_telemetry lib.rs: serialize register/unregister under a Mutex and honor register()'s status (return false on failure) so wrapper state can't diverge. - wxc/lxc main.rs: route post-init config/policy/init early-exit failures through telemetry::emit_early_exit so they emit MXC.Execution/MXC.Error (makes ConfigError/PolicyError reachable). - docs/telemetry.md: narrow the 'every execution' claim (state-aware not instrumented), mark the pipeline-GUID wiring as a follow-up. - smoke test: derive the provider GUID from the name, fix the init/emit comment, and fail (not 'inconclusive') on zero captured events. Co-authored-by: Copilot <[email protected]>
Add comments explaining why MXC.Execution is Informational (routine completion record) and MXC.Error is Warning rather than Error/Critical (it reports an expected operational failure of a sandboxed run, not an MXC defect; downstream pipelines treat Error/Critical as product faults). No behavior change. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Canonicalizes the MXC_TELEMETRY_PROVIDER_GROUP_GUID value with the uuid crate and emits the lowercase hyphenated form into the generated provider definition, replacing the hand-rolled validator. uuid is added only as a build- and dev-dependency, not a runtime dependency. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Threads the codebase Logger into the wxc_common telemetry init wrapper so that an enabled-but-failed ETW provider registration emits a diagnostic line instead of being silently swallowed. Logging stays in wxc_common (not the mxc_telemetry leaf crate) to avoid a circular dependency. Co-authored-by: Copilot <[email protected]>
Places the telemetry doc in its own docs/telemetry/ folder to match the per-area docs convention (docs/lxc-support, docs/isolation-session, ...), and updates the README link. Co-authored-by: Copilot <[email protected]>
9da4978 to
31f6573
Compare
…e instrumentation Follow-up implementing the telemetry issues deferred from the original TraceLogging ETW PR (#493): crash/panic telemetry via a global panic hook (#561), state-aware lifecycle instrumentation with an `mxc.phase` field (#562), cancellation telemetry from the console control handler (#563), non-zero-exit diagnostic parity across the executors (#564), and reconciliation of the `docs/schema.md` supported-version table (#565). All behind the existing `--experimental` + `experimental.telemetry.enabled` gate. The PII invariant is preserved: free-form error text is never emitted (bounded `FailureReason`/`error_type` and numeric exit codes only), and on non-Windows platforms all telemetry functions compile as no-ops. Also unifies the state-aware telemetry config on the typed `experimental.telemetry` field, extracts a global-free crash-emit test seam (making panic/cancellation mapping testable across any backend/phase), and rejects a malformed (non-object) `experimental` block consistently with the one-shot path. Resolves #561 Resolves #562 Resolves #563 Resolves #564 Resolves #565 Co-authored-by: Copilot <[email protected]>
…e instrumentation (#624) * telemetry: implement deferred crash/cancellation/state-aware lifecycle instrumentation Follow-up implementing the telemetry issues deferred from the original TraceLogging ETW PR (#493): crash/panic telemetry via a global panic hook (#561), state-aware lifecycle instrumentation with an `mxc.phase` field (#562), cancellation telemetry from the console control handler (#563), non-zero-exit diagnostic parity across the executors (#564), and reconciliation of the `docs/schema.md` supported-version table (#565). All behind the existing `--experimental` + `experimental.telemetry.enabled` gate. The PII invariant is preserved: free-form error text is never emitted (bounded `FailureReason`/`error_type` and numeric exit codes only), and on non-Windows platforms all telemetry functions compile as no-ops. Also unifies the state-aware telemetry config on the typed `experimental.telemetry` field, extracts a global-free crash-emit test seam (making panic/cancellation mapping testable across any backend/phase), and rejects a malformed (non-object) `experimental` block consistently with the one-shot path. Resolves #561 Resolves #562 Resolves #563 Resolves #564 Resolves #565 Co-authored-by: Copilot <[email protected]> * telemetry: crash/cancellation/state-aware instrumentation + MS-CV correlation Addresses the PR #624 review round. Squashed follow-up to the initial deferred-telemetry commit; folds in the review fixes, the correlation rework, and the adversarial-review hardening. Telemetry (experimental, gated on --experimental + experimental.telemetry): - Crash and cancellation instrumentation with a panic-free, message-free panic hook chained onto the previous hook, wired symmetrically across all three executors (wxc-exec, lxc-exec, mxc-exec-mac). macOS has no ETW sink today, so its emits are structural no-ops kept for parity. - Exactly-once terminal-emit slot made resettable and testable (#[cfg(test)] reset seam), so the panic hook / control handler vs emit_completion race is covered rather than only the inactive no-op path. - Capture-sink / force-active seam over the mxc_telemetry log_execution / log_error calls so emit_panic / emit_cancellation glue (process globals, is_active/already_emitted guards, backend/phase/exit-code) is unit-tested. - Cancellation emit-before-cleanup ordering locked in with a handler-level test (the OS-budget guarantee from the PR description). - Full phase x outcome matrix for plan_state_aware across {provision, start, exec, stop, deprovision} x {success, non-zero guest exit, MxcError}. Cross-phase correlation (Microsoft Correlation Vector, MS-CV): - Replaces the initial per-lifecycle sandbox_id with a full MS-CV (correlation_vector.rs). Seeded at provision, returned in its result, and relayed verbatim by the client into each later phase (emitted under __TlgCV__). The executor is the trust boundary: on each non-provision phase it validates the relayed value and spins a fresh child element off a mutable base, passes an already-frozen vector through unchanged, and reseeds a brand-new base if the relayed value is absent or malformed. - New optional correlationVector wire field (wire.rs), regenerated dev schema and generated SDK wire types, SDK + state-aware plumbing, and telemetry/schema/state-aware docs. - Hardened MS-CV operators/planner per adversarial review: tightened the SPIN_ENTROPY_BYTES compile-time guard (< 4 so the coarse counter still contributes to the 32-bit spun element), documented the deterministic os_random_bytes test seam, and corrected the frozen-vector pass-through wording across wire.rs / schema.md / SDK docs. Backend error surfacing (issue #564): - Shared emit_backend_error_envelope in wxc_common::script_runner so MXC never exits non-zero on an infrastructure failure without first printing a machine-readable {"error":{"code":"backend_error",...}} envelope on stderr. Wired into wxc-exec / lxc-exec / mxc-exec-mac and the state-aware finalize path; covered by a macOS seatbelt integration test (blockedHosts rejection) plus unit tests. Co-authored-by: Copilot <[email protected]> Copilot-Session: 404ca98b-224b-485e-bfe6-c092c5c500d0 * chore: re-trigger CLA/PR checks Co-authored-by: Copilot <[email protected]> Copilot-Session: fddfe62a-90da-425e-868f-fae6958d68c6 --------- Co-authored-by: Copilot <[email protected]>
📖 Description
Add experimental telemetry support using the tracelogging crate for pure Rust ETW event emission. No C++ shim or WIL dependency required.
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 UTC when telemetry provider is correctly enabled.
✅ Checklist
📋 Issue Type
Microsoft reviewers: PR builds do not auto-run (ADO policy). Comment /azp run to start MXC-PR-Build. See docs/pull-requests.md.
Microsoft Reviewers: Open in CodeFlow