1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Process-wide consent gate for telemetry, visible from both the bin
//! and lib crates.
//!
//! `src/telemetry.rs` is currently bin-private (declared as `mod
//! telemetry` in `main.rs`). Code that lives in modules also declared
//! by `lib.rs` (e.g. `src/packages/*`, `src/observability/*`) cannot
//! reach `crate::telemetry::is_enabled()` when compiled as part of the
//! lib crate (e.g. during `cargo test`).
//!
//! This module provides a thin `AtomicBool` gate that the lib-side
//! observability module can read, populated by `telemetry::init` at
//! startup. The atomic lives in observability so any module declared
//! by `lib.rs` can reach it. At runtime only one copy of the static
//! is live (the bin-compiled one when `jarvy` is running; the lib copy
//! only matters during `cargo test`).
//!
//! This is the load-bearing piece that prevents `package.*` /
//! `packages.*` events from leaking to OTLP when the user explicitly
//! set `telemetry.enabled = false` — the prior round emitted raw
//! `tracing::*` to dodge the visibility wall, which broke the
//! documented consent contract.
use ;
static TELEMETRY_ENABLED: AtomicBool = new;
/// Mark telemetry as enabled. Called from `telemetry::init` at startup
/// once the resolved configuration is known. Idempotent.
/// Read the current consent state. Callers in `src/packages/*` and
/// other lib-side modules use this in place of
/// `telemetry::is_enabled()` so events fire only when the user has
/// consented to (or not yet opted out of) telemetry.
/// Run `f` only when the gate is on. Single-shot wrapper that lifts
/// the `if is_enabled() { f() }` pattern out of every call site —
/// previously open-coded in `src/registry_remote/sync.rs` and
/// missing entirely from `src/commands/registry_cmd.rs`,
/// `src/tools/plugins.rs`, and `src/registry_remote/cache.rs`,
/// which leaked `registry.*` events to OTLP when the user had set
/// `telemetry.enabled = false`. Routing every emit through this
/// helper closes that contract.