PhoenixReplay.Capture.TelemetryEvents (PhoenixReplay v0.6.2)

Copy Markdown View Source

Records telemetry events captured by the configured PhoenixReplay.Collectors.

Each collector is attached once, when the application starts. Its handler runs in the process that emitted the event and handles it in a fixed order:

  1. Finds the session of the emitting process, or of the first of its $callers that has one, so start_async/3, assign_async/3 and Task work belongs to the LiveView that started it. Events no session claims stop here, at the cost of one ETS lookup per process.
  2. Lets the collector capture or skip the event.
  3. Passes captured metadata through the session's PhoenixReplay.Sanitizer. Text such as SQL is masked later, when the recording is saved, by the session's PhoenixReplay.Redactor.
  4. Records a :telemetry event, unless the collector reached its :limit for the session, in which case the event is counted as dropped.

:telemetry permanently detaches a handler that raises, so a collector that raises is reported with [:phoenix_replay, :collector, :exception] instead; see PhoenixReplay.Telemetry.

Summary

Functions

Attaches the configured collectors. Called by PhoenixReplay.Capture.Handlers.

The $callers of the current process, which Task sets.

Detaches the collectors attached with prefix.

Handles a telemetry event for a collector.

Functions

attach(config, prefix \\ __MODULE__)

@spec attach(PhoenixReplay.Config.t(), term()) :: :ok

Attaches the configured collectors. Called by PhoenixReplay.Capture.Handlers.

Handlers are identified by {prefix, index}.

callers()

@spec callers() :: [pid()]

The $callers of the current process, which Task sets.

detach(prefix \\ __MODULE__)

@spec detach(term()) :: :ok

Detaches the collectors attached with prefix.

handle_event(event, measurements, metadata, arg)

@spec handle_event([atom()], map(), map(), {module(), keyword(), pos_integer()}) ::
  :ok

Handles a telemetry event for a collector.