MetrixWire (MetrixWire v0.2.1)

Copy Markdown View Source

Zero-config APM SDK for Elixir.

Add the dependency and set METRIXWIRE_KEY (or config :metrixwire, api_key: ...) and it is fully automatic — every HTTP request becomes a trace, and every DB query / outbound HTTP call within it becomes a span. There is no manual span API.

The SDK ships its own OTP application (MetrixWire.Application) which, on boot, starts the transport GenServer and attaches every :telemetry handler. Phoenix, Ecto, Finch and Tesla all emit telemetry, so a single handler set instruments the whole app with zero code changes. Bare Plug apps add one line: plug MetrixWire.Plug.

Non-blocking: traces are batched in a GenServer and flushed off the request path with a short timeout, and all transport errors are swallowed — instrumentation must never throw into or block the host application.

Summary

Functions

Attach an exception to the active trace. Escape hatch mirroring the other SDKs — NOT a manual span API; requests/queries are still captured automatically.

Whether span source-location capture is on.

Whether the SDK is enabled (configured with an API key).

The configured ingest endpoint URL, or nil.

Enqueue a finished trace for delivery. Internal — used by instrumentation.

Build the exception meta map from an arbitrary error + optional stacktrace. Keeps the top ~8 backtrace frames.

Manually flush the queue (e.g. before a short-lived process exits).

ISO8601 UTC with millisecond precision, e.g. "2026-07-15T10:00:00.000Z".

ISO8601 string for ms_ago milliseconds before now (used for span start).

Total memory used by the Erlang VM, in bytes. Best-effort.

Memory delta in MB since start_bytes. Returns 0 when unavailable.

Monotonic milliseconds — safe for measuring durations (never goes back).

Functions

capture_exception(error, stacktrace \\ nil)

Attach an exception to the active trace. Escape hatch mirroring the other SDKs — NOT a manual span API; requests/queries are still captured automatically.

capture_source?()

Whether span source-location capture is on.

enabled?()

Whether the SDK is enabled (configured with an API key).

endpoint()

The configured ingest endpoint URL, or nil.

enqueue(trace)

Enqueue a finished trace for delivery. Internal — used by instrumentation.

exception_meta(error, stacktrace \\ nil)

Build the exception meta map from an arbitrary error + optional stacktrace. Keeps the top ~8 backtrace frames.

flush()

Manually flush the queue (e.g. before a short-lived process exits).

iso8601(dt)

ISO8601 UTC with millisecond precision, e.g. "2026-07-15T10:00:00.000Z".

iso8601_ago(ms_ago)

ISO8601 string for ms_ago milliseconds before now (used for span start).

memory_bytes()

Total memory used by the Erlang VM, in bytes. Best-effort.

memory_delta_mb(start_bytes)

Memory delta in MB since start_bytes. Returns 0 when unavailable.

monotonic_ms()

Monotonic milliseconds — safe for measuring durations (never goes back).