TraceGuard.Telemetry (trace_guard v0.1.0)

Copy Markdown View Source

Internal module. Not part of TraceGuard's public API: it may change in any release. Use the functions in TraceGuard instead.

Attaches TraceGuard's handlers to selected :telemetry events.

Telemetry eventTimeline event
[:phoenix, :endpoint, :start]phoenix.endpoint.start
[:phoenix, :endpoint, :stop]phoenix.endpoint.stop
[:phoenix, :router_dispatch, :start]phoenix.router_dispatch.start
[:phoenix, :router_dispatch, :stop]phoenix.router_dispatch.stop
[:phoenix, :router_dispatch, :exception]phoenix.router_dispatch.exception + failure
[:phoenix, :error_rendered]phoenix.error_rendered + failure (fallback)
prefix ++ [:query] per configured Ecto repoecto.query

Metadata filtering

Telemetry metadata routinely contains the whole Plug.Conn, Ecto query parameters, results and options. Handlers never store metadata maps wholesale: each handler copies an explicit allow-list of fields, converted to plain strings and numbers.

Safety

Handlers run synchronously in the emitting (request) process. They only touch that process's dictionary, do no I/O, and rescue every error; :telemetry permanently detaches handlers that raise, which would silently disable tracing.

Summary

Functions

Attaches (or re-attaches) the handlers for the current configuration.

Detaches TraceGuard's handlers.

The telemetry events TraceGuard attaches to for the given configuration.

Functions

attach()

@spec attach() :: :ok

Attaches (or re-attaches) the handlers for the current configuration.

Idempotent and safe to call concurrently: detach + attach is not atomic in :telemetry, so callers are serialized with a node-local lock.

detach()

@spec detach() :: :ok

Detaches TraceGuard's handlers.

events(config)

@spec events(TraceGuard.Config.t()) :: [[atom()]]

The telemetry events TraceGuard attaches to for the given configuration.