lens.helpers
Telemetry helper utilities: span_cm, managed_span, trace_fn, safe_set_span_attributes.
Module Contents
Functions
Data
API
Explicit-lifecycle span guarded by a span-group check.
When the group is disabled the body executes normally and None is
yielded — no span object is created. When enabled, the span is started,
its context attached, and always ended in a finally block.
Parameters:
Span group name. If not enabled, this is a zero-overhead no-op.
Span name.
OTel tracer. Defaults to the global tracer.
Key/value pairs set as span attributes.
Return '[REDACTED]' if key is in redact_keys, else value.
Set span attributes, silently skipping non-scalar values.
OTel span attributes must be scalars (bool, int, float, str) or sequences of scalars. Redacts string values whose keys are in redact_keys.
Context manager that creates an OTel span for a code block.
Safe to use with no-op tracers.
Parameters:
Span name.
OTel tracer. Defaults to the global tracer.
If True, record exceptions as span events.
Key/value pairs set as span attributes.
Decorator that wraps a function in a group-gated OTel span.
The span group is checked at call time (not decoration time).
Parameters:
Span group name.
OTel span name.
OTel tracer. Defaults to the global tracer.
Returns:
A decorator that wraps the target function.