pub fn opaque_tenant_id(tenant: &Option<String>) -> Option<u64>Expand description
Reduce a raw tenant subject to an opaque 64-bit id for metric attrs and tenant-safe logs.
The tenant subject is never carried verbatim in metrics or logs (metrics are
aggregatable across tenants and must not leak identity). The hash is a
SipHash keyed with process-random keys (RandomState, drawn from the OS
RNG): an unkeyed hash such as DefaultHasher::new() is offline-enumerable —
anyone can precompute the ids of guessed low-entropy subjects (#1261 review).
With a random key the id is stable within the process but cannot be
precomputed or correlated across deployments. Returns None when no tenant
is in scope.
This is pure std and available regardless of the otel feature or target so
it can be unit-tested hermetically and reused by tenant-safe logging.