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
/**
* Vendor-neutral observability sink.
*
* The SDK emits one observation per client operation. It never transports
* anything: there is deliberately no egress primitive in this module — not
* even imported — so a consumer can prove by inspection that the SDK cannot
* phone home. Vendor bindings live in separate opt-in packages.
*
* Emission must never affect an operation: a throwing observer is swallowed,
* and observers are invoked synchronously so an operation's timing and
* async-ness are unchanged.
*/
let currentObserver = null;
/**
* Register the observation sink. Replaces any existing observer.
*
* @param {((observation: object) => void) | null} observer
* @returns {() => void} unsubscribe
*/
export
/** @returns {boolean} whether anyone is listening. */
export
/**
* Deliver one observation. `sensitive` is omitted from the delivered object
* unless explicitly supplied, so `"sensitive" in observation` is a truthful
* test of whether the high-fidelity channel is active.
*
* @param {{op: string, outcome: "ok" | "error", durationMs: number, sensitive?: object}} fields
*/
export
/** Test-only: drop the registered observer. */
export