Skip to main content

Module EmitWithTraceparent

Module EmitWithTraceparent 

Source
Expand description

Outbound emit wrapper that stamps a W3C _traceparent field onto every JSON payload before forwarding to app_handle.emit(...). Sky’s Workbench/Electron/TraceparentBridge.ts extracts the header at the receiving end so spans emitted inside the handler attach to the same Jaeger trace. Release builds short-circuit to a plain emit(...) via cfg!(debug_assertions). Wrap app_handle.emit(name, payload) so every outbound Sky-side Tauri event carries a W3C _traceparent field on its JSON payload. Sky’s Workbench/Electron/TraceparentBridge.ts::ConsumeFromPayload strips the field at the receiving end, registers the trace context for the duration of the event handler, and Sky’s OTELBridge reads it so spans emitted inside the handler attach to the same trace.

Migration plan: replace app_handle.emit(...) call sites incrementally with EmitWithTraceparent::Fn(...). Both paths coexist - the bridge tolerates payloads without _traceparent.

Functions§

Fn
Emit a Tauri event with a _traceparent field merged into its JSON payload. Payload must be a JSON object (or null - we’ll build one). Non-object payloads pass through unchanged so existing emit sites that send raw arrays / numbers / strings stay correct.
FnMap
Variant for callers that already serialise into a serde_json::Map.