Skip to content

telemetry: emit crash/panic telemetry via a global panic hook #561

Description

@RamonArjona4

Description of the new feature / enhancement

MXC currently installs no global std::panic::set_hook in either wxc (src/core/wxc/src/main.rs) or lxc (src/core/lxc/src/main.rs). If MXC itself panics — an actual MXC defect, the truest "crash" — no telemetry is emitted, so these failures are invisible. The existing MXC.Error event only fires on instrumented one-shot completion/early-exit paths, never on a panic.

Add a global panic hook that, when telemetry is active, emits a single MXC.Error event before the process unwinds/aborts, so crashes become observable.

Proposed technical implementation details

  • Install a std::panic::set_hook in both wxc and lxc main, right after telemetry init (src/core/wxc/src/main.rs ~line 702; src/core/lxc/src/main.rs ~line 211).
  • Emit via a new helper in src/core/wxc_common/src/telemetry/mod.rs (alongside emit_completion/emit_early_exit). Consider a dedicated FailureReason such as InternalError (the enum lives in events.rs).
  • Data minimization: do NOT emit the panic message text (may contain paths/PII per our existing policy). Emit only the bounded category (+ optionally backend).
  • Constraint: emission only works if telemetry was already initialized (provider registered). Default panic strategy is unwind, so the hook runs and existing Drop/ParkedDaclGuard cleanup still executes.
  • Known limitation to document: failures before telemetry init (base64 decode, JSON parse, load_request) fundamentally cannot emit telemetry because the experimental.telemetry.enabled flag is only known after config parse.

Deferred from PR #493.

Metadata

Metadata

Assignees

Labels

Issue-FeatureIt's a new feature request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions