PhoenixReplay.Session.Monitor (PhoenixReplay v0.6.2)

Copy Markdown View Source

Follows each recorded session from its first event to storage.

Each recorded process is monitored. While it runs, the monitor checks its sessions periodically and writes a session's buffered events to storage as a chunk, with PhoenixReplay.Session.Flusher, once PhoenixReplay.Session.TailSampling decides to keep it and :flush says a chunk is due. Keeping is decided from the events seen so far, which are observed incrementally, and never turns back, so nothing is written that would be discarded later.

When the process exits abnormally, its exit reason is recorded as an :exit event. The session is then discarded, or saved by PhoenixReplay.Session.Finalizer in a supervised task, after any flush in flight. The task closes the buffer once it saved the recording or gave up, and emits its PhoenixReplay.Telemetry event after that, so a handler observes the finished state. Sessions being saved are marked in the buffer, so a restarted monitor leaves them to their task.

On shutdown the monitor waits for saves and flushes in flight. On start it re-attaches to every session already in PhoenixReplay.Session.Buffer, so a restart loses no recordings.

Summary

Functions

Gives the monitor time to drain on shutdown: the application waits for recordings being saved or written when it stops.

Starts the monitor registered under its module name.

Starts monitoring the session recorded by pid.

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Gives the monitor time to drain on shutdown: the application waits for recordings being saved or written when it stops.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts the monitor registered under its module name.

watch(pid, id)

@spec watch(pid(), PhoenixReplay.Recording.id()) :: :ok

Starts monitoring the session recorded by pid.