Called with no arguments after metrana.init, it anchors to that run and takes the run’s credentials and delivery
settings: every delivery argument left at its default above is the run’s value, except compression. An explicit
value is the caller’s, None included where it means something (disk=None for no spool,
ack_stall_timeout_secs=None for no watchdog, max_send_retries=None for unbounded retries). Anchored elsewhere,
an argument left at its default is the tracing default below.
metrana.tracing.Tracer(workspace_name, project_name, run_name=None, *, ...) takes the same keyword arguments
with those defaults spelled out, without the run-derived fallbacks.
These are the logger’s settings under the same names, apart from queue_max_bytes, the tracer’s own; see
init() configuration for each one’s meaning. A tracer derived
from the run inherits the run’s values for all of them except compression.
Argument
Tracing default
Note
compression
zstd
The logger defaults to off: float payloads do not compress, trace bodies are text and shrink several-fold.
disk
The default spool under METRANA_DISK_SPOOL_DIR, best-effort
Traces spool under a #traces subtree of it, apart from the run’s spool.
The send queue’s bound, in bytes rather than the logger’s queue_capacity count: one update can carry bodies of up to 16 MiB. Never inherited from the run.
The share of traces recorded, decided once per root: 1.0 every trace, 0.01 one in a hundred. A root left out is an inert NoopSpan, children included. None reads METRANA_TRACING_SAMPLE_RATE, which itself defaults to 1.0; an unusable value there falls back to 1.0, with a warning. Outside 0.0 to 1.0 raises ValueError.
Environment variable
Meaning
METRANA_TRACING_DISABLED
1 / true / yes / on switches tracing off for the process: init() builds nothing and every trace, span and decorated call is inert.
METRANA_TRACING_SAMPLE_RATE
The sample_rate when init() / Tracer are not given one.
init() called without a target and without an active run to derive one from — or get_tracer() with no tracer, no run, after tracing.close(), or with tracing disabled. A trace opened in that state is inert instead.
NoMetranaApiKeyError
No API key from any source.
MetranaSpoolUnavailableError
An explicitly given spool directory cannot be used. The default spool is dropped with a warning instead.
MetranaLoggerInitError
The tracer cannot start for another reason, e.g. an endpoint that does not parse.
A second tracing.init() while a tracer exists — one built implicitly from the run included — closes that tracer,
delivering what it holds, and replaces it with the new settings.