Skip to navigation

lens.span_utilities

View as Markdown

Utilities for emitting spans from caller-supplied timestamps.

Module Contents

Functions

NameDescription
_finite_epoch_seconds-
emit_spanEmit a completed span for an interval in Unix-epoch seconds.
linux_process_create_timeReturn process creation time in Unix-epoch seconds from Linux /proc data.

Data

_LOGGER

_NANOSECONDS_PER_SECOND

API

lens.span_utilities._finite_epoch_seconds(
value: float | str | decimal.Decimal,
label: str
) -> decimal.Decimal
lens.span_utilities.emit_span(
tracer: opentelemetry.trace.Tracer | None,
name: str,
start_epoch_seconds: float | str | decimal.Decimal,
end_epoch_seconds: float | str | decimal.Decimal,
group: str | None = None,
context: opentelemetry.context.Context | None = None,
attributes: dict[str, typing.Any] | None = None
) -> opentelemetry.trace.Span | None

Emit a completed span for an interval in Unix-epoch seconds.

Unless context is supplied, use the context active at this call, not the context that was active during the interval. Pass Context() for a root span. The emitted span is never made current.

Pass None for the default tracer. A disabled group returns None before validation. Otherwise return the completed span.

Inverted timestamps always set the end to the start and warn about possible clock skew. The span records inverted.skew=True, the original timestamps, and the inversion amount. Parent context and caller attributes are retained. Timestamps must be finite. There is no inversion tolerance or rejection threshold.

lens.span_utilities.linux_process_create_time(
stat_text: str | None = None,
uptime_text: str | None = None,
read_time: float | None = None,
stat_path: str | os.PathLike[str] = '/proc/self/stat',
uptime_path: str | os.PathLike[str] = '/proc/uptime',
clock_ticks_per_second: int | None = None
) -> float

Return process creation time in Unix-epoch seconds from Linux /proc data.

lens.span_utilities._LOGGER = logging.getLogger(__name__)
lens.span_utilities._NANOSECONDS_PER_SECOND = 1000000000