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
//! Wiring observability for `whatsapp-rust`.
//!
//! Run with:
//! cargo run --example observability --features tracing
//!
//! The library only *emits* `tracing` spans/events (and keeps its existing `log`
//! calls). It never installs a subscriber and never depends on OpenTelemetry —
//! that is the application's job, shown here.
//!
//! Two things happen below:
//!
//! 1. A `tracing-subscriber` is installed. Its default `tracing-log` feature
//! bridges the library's existing `log::{info,warn,error}!` calls into
//! tracing, so they become events attached to the active `wa.*` span.
//! 2. Span/level/target filtering is driven by `RUST_LOG` (EnvFilter), e.g.
//! `RUST_LOG="info,whatsapp_rust=debug,wacore=debug"`. The library groups
//! spans under `wa.*` names and reuses its `target: "Client/AppState"`-style
//! targets, so you can filter per area.
//!
//! IMPORTANT: do NOT enable the `log` feature on the `tracing` crate together
//! with a log->tracing bridge — that recurses. This crate already pins
//! `tracing` with `default-features = false` so the hazard cannot happen.
//!
//! PII note: the bridged `log` lines surface alongside the redacted `wa.*` spans.
//! The library renders JIDs and Signal addresses in its own log messages through
//! `Jid::observe()` / `observe_protocol_address()` (phone numbers become
//! `pn#<keyed-token>`), so the `whatsapp_rust`/`wacore` log lines carry the same
//! redaction as the span fields. Your own application code is a separate leak
//! path: any raw JID/phone you log reaches the exporter under your own targets,
//! and dropping the library targets does nothing for it — scrub your app's logs
//! with `Jid::observe()` too. The `tracing-pii` cargo feature (off) renders raw
//! numbers for local debugging only.