MetrixWire.Plug (MetrixWire v0.2.3)

Copy Markdown View Source

Drop-in Plug for bare Plug apps (no Phoenix). Add one line to your pipeline:

plug MetrixWire.Plug

and every request opens exactly one trace, with Ecto/Finch spans attaching automatically via the process dictionary. Phoenix apps need NO such line — Phoenix emits [:phoenix, :endpoint, :*] telemetry which the SDK already hooks.

This module is Plug-compatible without a compile-time dependency on :plug: it implements init/1 and call/2 structurally, and it registers a before_send callback so the trace closes with the final response status. Defensive at every step — instrumentation must never change the response.