Expand description
§Telemetry - shared dual-pipe (PostHog + OTLP) for every Rust Element
Single source of truth for the sidecar telemetry surface. Mountain
keeps its own compile-time-baked Binary/Build/PostHogPlugin/*
(the build.rs cargo:rustc-env route guarantees release builds drop
every byte). All other Rust elements (Air, Echo, Rest, Grove, Mist,
SideCar) read configuration at runtime through this module:
ⓘ
use CommonLibrary::Telemetry::{Initialize, Tier};
Initialize::Fn(Tier::Air); // call once during bootAll capture functions are no-ops in release builds
(cfg!(debug_assertions)) and short-circuit on Capture=false / per-pipe
toggles at runtime.
§Layout (one export per file)
Tier::Tier- enum identifying the calling sidecarConfiguration::Fn- runtime env readIsAllowed::PostHog,IsAllowed::OTLP- gatesClient::CLIENT-OnceLock<posthog_rs::Client>DistinctId::Fn- stable per-machine identityCaptureEvent::Fn,CaptureError::Fn,CaptureSession::Fn- PostHogEmitOTLPSpan::Fn- raw HTTP OTLP exporterInitialize::Fn-Tier-tagged boot
Modules§
- Capture
Error - Emit
land:<tier>:errorwitherror_tag+error_message. The Errors & Reliability dashboard rolls these up across Mountain / Cocoon / Sky / sidecars viaevent LIKE 'land:%:error'. - Capture
Event - Emit a named PostHog event. Stamps the calling
Tierplus the standard Land identity ($app,$app_version,$build_mode,$component,$tier) so dashboards can pivot by tier without caller changes. - Capture
Session - Emit
land:<tier>:session:startwith pid / OS / arch. Called once byInitialize::Fnso the Boot & Startup Performance dashboard sees one start event per sidecar process. - Client
- Process-wide PostHog client singleton. Populated once by
Initialize::Fn; everyCapture*::Fnreads through this static. Sidecars share one client per process, like Mountain’sBinary/Build/PostHogPlugin/Client. - Configuration
- Runtime read of
.env.Land.PostHog. Sidecars don’t have their ownbuild.rsenv-bake (Mountain does, for compile-time tree-shake) - they read at boot viastd::env::var. Mountain’sHydrateRuntime Environment::Fnpopulates these into the spawned process’s env so sidecars launched as Mountain children pick them up automatically. - Distinct
Id - Stable distinct ID for the dev session. Mirrors Mountain’s
Binary/Build/PostHogPlugin/DistinctIdso a single dev run merges into one PostHog person across every sidecar. - EmitOTLP
Span - Fire-and-forget OTLP span exporter. Lifted from Mountain’s
IPC/DevLog/EmitOTLPSpanso Air / Echo / Rest / Grove / Mist / SideCar all share the same raw HTTP path. Single failed POST flipsOTLP_AVAILABLEto false so a missing collector doesn’t tax every emit. Release builds compile out viacfg!(debug_assertions). - Initialize
- Sidecar boot. Idempotent: subsequent calls are no-ops because
OnceLock::setreturnsErr. Pass theTierso every emitted event is tagged correctly without per-call boilerplate. - IsAllowed
- Compile-time + runtime gates.
cfg!(debug_assertions)strips both pipes from release builds;Captureis the master kill,Report/OTLPEnabledare per-pipe toggles. Cached after first read so the hot path is one atomic load. - Tier
- Identifier for the calling Element. Tags every emitted event so the
Errors & Reliability dashboard can pivot by
$tier. - Traceparent
- W3C
traceparentheader builder + parser. Used by every emit / RPC site that crosses a tier boundary (Mountain → Sky tauri events, Mountain → Cocoon gRPC, Sky → Mountain TauriInvoke, Cocoon → Mountain gRPC). The format is the standardversion-traceid-parentid-flagsfrom https://www.w3.org/TR/trace-context/.