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
//! Correlation ids (SPEC §6).
//!
//! - `run_id` — a UUIDv4 minted once at [`init`](crate::init), stamped on every record, so one
//! process run is groupable across rotated files and restarts are distinguishable.
//! - `op_id` — a span field a consumer attaches to a top-level operation; it flattens onto every
//! event inside the span (handled by the JSON layer), so it is a convention, not code here.
//! - `parent_op_id` — read once from the `DIG_OP_ID` env var, tying this run to the operation in the
//! parent process that spawned it (installer → service; updater broker → worker).
use Uuid;
/// The reserved span-field name a consumer uses to tag a top-level operation (SPEC §6).
pub const OP_ID_FIELD: &str = "op_id";
/// The env var a parent process sets in a child's environment to propagate its operation id.
pub const ENV_DIG_OP_ID: &str = "DIG_OP_ID";
/// Mint a fresh run id for this process run.
/// Read the propagated parent operation id from an injected env-getter: the `DIG_OP_ID` value when
/// present + non-blank, else `None`. Pure, so the pickup is testable without the process environment.
/// Read the parent operation id from the real environment. See [`parent_op_id`].