Weavr.Telemetry (Weavr v1.0.0)

Copy Markdown View Source

Telemetry event dispatch used internally by Weavr.HTTP.

weavr integrates with the standard :telemetry library used across the Elixir ecosystem (Phoenix, Ecto, Tesla, Req, ...). If your application already depends on :telemetry (directly, or transitively through Phoenix/Ecto), Weavr.attach_default_logger/1 and your own :telemetry.attach/4 handlers work exactly as you'd expect — weavr calls straight through to the real :telemetry.execute/3.

If :telemetry is not loaded at all (for example, in a minimal script with no dependencies), this module falls back to a tiny built-in dispatcher supporting the same attach/4 and execute/3 contract, so weavr never requires :telemetry as a hard dependency.

Events emitted by this library:

  • [:weavr, :request, :start] - measurements: %{system_time: ...}
  • [:weavr, :request, :stop] - measurements: %{duration: native_time}
  • [:weavr, :request, :exception] - measurements: %{duration: native_time}

All three carry metadata: %{method:, url:, attempt:, status?:, error?:} plus anything passed via :telemetry_metadata on the request.

Summary

Functions

Attaches a handler function for a given telemetry event (a list of atoms, e.g. [:weavr, :request, :stop]) or a list of such events.

Functions

attach(handler_id, events, function, config)

Attaches a handler function for a given telemetry event (a list of atoms, e.g. [:weavr, :request, :stop]) or a list of such events.

Mirrors :telemetry.attach/4. Only used by the fallback dispatcher; if real :telemetry is loaded, prefer calling :telemetry.attach/4 directly so other libraries' handlers can also observe these events.