Squidie.Runtime.Trace (squidie v0.3.7)

Copy Markdown View Source

Durable trace context for Squidie runtime commands and work.

Trace contexts are persisted as plain atom-key maps. Identifiers follow the W3C Trace Context sizes and lowercase hexadecimal representation without depending on process-local tracing state.

Summary

Types

t()

A normalized, version-tolerant durable trace map.

Functions

Creates a durable child span from a normalized parent trace.

Creates a new root trace with W3C-compatible identifiers.

Validates and canonicalizes atom- or string-key trace input.

Returns whether a value is a valid normalized trace context.

Types

error()

@type error() :: {:invalid_trace, term()}

t()

@type t() :: %{
  :trace_id => String.t(),
  :span_id => String.t(),
  optional(:parent_span_id) => String.t(),
  optional(:causation_id) => String.t(),
  optional(:tracestate) => String.t()
}

A normalized, version-tolerant durable trace map.

Functions

child_of(parent, causation_id)

@spec child_of(t() | map(), String.t() | nil) :: {:ok, t()} | {:error, error()}

Creates a durable child span from a normalized parent trace.

new_root(opts \\ [])

@spec new_root(keyword()) :: {:ok, t()} | {:error, error()}

Creates a new root trace with W3C-compatible identifiers.

normalize(trace)

@spec normalize(term()) :: {:ok, t()} | {:error, error()}

Validates and canonicalizes atom- or string-key trace input.

valid?(trace)

@spec valid?(term()) :: boolean()

Returns whether a value is a valid normalized trace context.