telemetry: implement deferred crash/cancellation/state-aware lifecycle instrumentation#624
Open
RamonArjona4 wants to merge 1 commit into
Open
telemetry: implement deferred crash/cancellation/state-aware lifecycle instrumentation#624RamonArjona4 wants to merge 1 commit into
RamonArjona4 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the remaining deferred experimental telemetry work across executors and the state-aware lifecycle, adding crash/panic and cancellation instrumentation while tightening the “non-zero exit must surface a diagnostic” contract.
Changes:
- Add lock-free “provider active” tracking and a new
mxc.phasefield to telemetry events. - Add a shared crash/cancellation planning + exactly-once terminal emission guard, plus state-aware lifecycle telemetry emission with per-phase attribution.
- Factor and reuse
emit_backend_error_envelopeso all executors print a machine-readable diagnostic on infrastructure failures before exiting non-zero; update docs accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/mxc_telemetry/src/lib.rs | Adds lock-free is_active() and threads phase through ETW event emission. |
| src/core/wxc/src/main.rs | Initializes/attributes telemetry on the state-aware path, installs panic hook, emits cancellation telemetry from console handler, and uses shared backend-error envelope emission. |
| src/core/wxc_common/src/telemetry/mod.rs | Adds panic/cancellation/state-aware telemetry plumbing, context attribution, and exactly-once terminal emission guard. |
| src/core/wxc_common/src/telemetry/events.rs | Extends event model with phase and updates error logging signature accordingly. |
| src/core/wxc_common/src/script_runner.rs | Introduces reusable emit_backend_error_envelope helper and basic unit coverage. |
| src/core/wxc_common/src/config_parser.rs | Rejects malformed non-object experimental in state-aware parsing; populates typed experimental.telemetry from raw state-aware block. |
| src/core/mxc_darwin/src/main.rs | Wires telemetry init/emit + panic hook and backend-error envelope emission for parity (no-op telemetry on macOS). |
| src/core/lxc/src/main.rs | Wires panic hook and backend-error envelope emission for parity. |
| docs/telemetry/telemetry.md | Documents state-aware phase telemetry plus crash/cancellation behavior and limitations. |
| docs/schema.md | Reconciles supported-version table with canonical schema version bounds. |
…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 <223556219+Copilot@users.noreply.github.com>
67b22aa to
c6a773a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📖 Description
Follow-up work implementing the telemetry issues deferred from the original
TraceLogging ETW PR (#493). Extends the experimental telemetry surface with
crash/panic, cancellation, and state-aware lifecycle instrumentation, and
tightens the non-zero-exit diagnostic contract, all behind the existing
--experimental+experimental.telemetry.enabledgate.std::panic::set_hookhandler(installed on both the one-shot and state-aware paths) emits a failure
MXC.Execution+MXC.Error(internal_error, exit code101) when anythread panics. No panic message or backtrace text is emitted — only the
bounded category and exit code — and the previous hook is chained so the
default stderr backtrace still prints.
stop/deprovision phases now emit telemetry carrying an
mxc.phasefield.close / shutdown) emits a cancellation event before cleanup.
non-zero exit never occurs without first surfacing a diagnostic; extracted
a shared
emit_backend_error_envelopefor lxc/darwin parity with wxc.docs/schema.mdsupported-versiontable with
schemas/schema-version.json.The change keeps the established PII invariant: free-form error text is never
emitted — only a bounded
FailureReason/error_typeenum and numeric exitcodes. On non-Windows platforms all telemetry functions compile as no-ops.
Includes review-driven hardening from adversarial + security + Copilot-style
reviews: the two telemetry-config parser paths were unified on the typed
experimental.telemetryfield, a global-free crash-emit test seam wasextracted (making panic/cancellation mapping testable across any
backend/phase), and the state-aware parser now rejects a malformed
(non-object)
experimentalblock consistently with the one-shot path.Limitation (documented in
docs/telemetry/telemetry.md): on backends thatrecover panics via
catch_unwind(the LXC runner), the panic hook records the101sentinel and claims the exactly-once terminal-emit slot, so the recoveredcompletion event is suppressed. There,
mxc.exit_code = 101is a"panic occurred" marker rather than the observed process exit code.
🔗 References
Resolves #561
Resolves #562
Resolves #563
Resolves #564
Resolves #565
Related (deferred follow-up, not resolved here):
equivalent), deferred from the field-comment mechanism discussion.
🔍 Validation
Automated (from
src/, toolchain 1.93):cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— no warningscargo test --workspace— all pass (adds panic/cancellation/state-awaretelemetry unit tests, pure crash/state-aware event-planner tests, and
state-aware parser tests including malformed/non-object
experimentalrejection)
CI gates run locally (all green):
check-version-sync,check-schema-versions,check-rust-toolchain-synccheck-schema-codegen+check-sdk-types-codegen(no wire-model drift)validate-configs(173 configs validated against the dev schema)Reviews: 7-axis adversarial review (findings fixed), security review (clean),
and an emulated GitHub Copilot PR review (three findings fixed).
✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes — n/a,Cargo.lockis unchanged📋 Issue Type
Microsoft Reviewers: Open in CodeFlow