MetrixWire.Trace (MetrixWire v0.2.2)

Copy Markdown View Source

One request / unit of work. Holds its spans and trace-level meta. Serialized to the exact ingest wire shape. Not part of any public API — instrumentation opens a trace on request start, accumulates spans, and closes it on request stop.

Structs are immutable, so the "active" trace lives in the process dictionary (a Phoenix/Plug request runs in one process) and every span append replaces it.

Summary

Functions

Append a span (kept in reverse; reversed on serialize).

Attach an exception + flag the trace as an error. Never throws.

Freeze the duration + memory delta when the trace closes.

Open a new trace. route/method may be refined later from telemetry.

Set a trace-level meta key.

Serialize to the ingest wire shape (string keys, camelCase).

Types

t()

@type t() :: %MetrixWire.Trace{
  duration_ms: term(),
  meta: term(),
  method: term(),
  route: term(),
  spans: term(),
  start_memory: term(),
  started_at: term(),
  started_mono: term(),
  status: term()
}

Functions

add_span(trace, span)

Append a span (kept in reverse; reversed on serialize).

capture_exception(trace, error, stacktrace \\ nil)

Attach an exception + flag the trace as an error. Never throws.

finalize(trace)

Freeze the duration + memory delta when the trace closes.

new(route, method)

Open a new trace. route/method may be refined later from telemetry.

put_meta(trace, key, value)

Set a trace-level meta key.

to_map(trace)

Serialize to the ingest wire shape (string keys, camelCase).