instrument_id (instrument v1.0.0)

View Source

Trace and Span ID generation per W3C TraceContext spec.

Provides cryptographically random ID generation and hex encoding/decoding.

Summary

Functions

Generates a random 64-bit span ID. The ID is guaranteed to be non-zero per W3C spec.

Generates a random 128-bit trace ID. The ID is guaranteed to be non-zero per W3C spec.

Converts a hex string to a span ID.

Converts a hex string to a trace ID.

Checks if a span ID is valid (non-zero).

Checks if a trace ID is valid (non-zero).

Converts a span ID to lowercase hex string.

Converts a trace ID to lowercase hex string.

Types

span_id/0

-type span_id() :: <<_:64>>.

trace_id/0

-type trace_id() :: <<_:128>>.

Functions

generate_span_id()

-spec generate_span_id() -> span_id().

Generates a random 64-bit span ID. The ID is guaranteed to be non-zero per W3C spec.

generate_trace_id()

-spec generate_trace_id() -> trace_id().

Generates a random 128-bit trace ID. The ID is guaranteed to be non-zero per W3C spec.

hex_to_span_id(Hex)

-spec hex_to_span_id(binary()) -> span_id().

Converts a hex string to a span ID.

hex_to_trace_id(Hex)

-spec hex_to_trace_id(binary()) -> trace_id().

Converts a hex string to a trace ID.

is_valid_span_id(SpanId)

-spec is_valid_span_id(span_id() | undefined) -> boolean().

Checks if a span ID is valid (non-zero).

is_valid_trace_id(TraceId)

-spec is_valid_trace_id(trace_id() | undefined) -> boolean().

Checks if a trace ID is valid (non-zero).

span_id_to_hex(SpanId)

-spec span_id_to_hex(span_id()) -> binary().

Converts a span ID to lowercase hex string.

trace_id_to_hex(TraceId)

-spec trace_id_to_hex(trace_id()) -> binary().

Converts a trace ID to lowercase hex string.