PhoenixReplay.Session.Finalizer (PhoenixReplay v0.6.2)

Copy Markdown View Source

Completes a finished recording and saves it with retries.

Runs inside a task started by PhoenixReplay.Session.Monitor, so redaction and the backoff sleeps block only that task. The events still in the buffer are redacted with the session's PhoenixReplay.Redactor and joined to the chunks already flushed to storage, see complete/3. If that fails, nothing is saved. Attempts and backoff come from the :persist configuration; the delay grows linearly with the attempt number.

Summary

Functions

Completes a buffered session's recording, for saving it or for showing it while it runs: redacts the events still in the buffer and puts the chunks already flushed to storage, which were redacted when they were written, before them.

Saves the buffered recording with persist/2, then closes its buffer and emits [:phoenix_replay, :recording, :persisted] or :failed.

Completes and saves the buffered recording, retrying the save until it succeeds or attempts run out. Returns the saved recording.

Functions

complete(recording, config, opts \\ [])

@spec complete(PhoenixReplay.Recording.t(), PhoenixReplay.Config.t(), keyword()) ::
  {:ok, PhoenixReplay.Recording.t()} | {:error, term()}

Completes a buffered session's recording, for saving it or for showing it while it runs: redacts the events still in the buffer and puts the chunks already flushed to storage, which were redacted when they were written, before them.

Takes the :progress option of PhoenixReplay.Redactor.redact_recording/3.

finish(recording, config)

Saves the buffered recording with persist/2, then closes its buffer and emits [:phoenix_replay, :recording, :persisted] or :failed.

The task does this itself, so a session is finished even if the monitor that started the task restarts meanwhile.

persist(recording, config)

@spec persist(PhoenixReplay.Recording.t(), PhoenixReplay.Config.t()) ::
  {:ok, PhoenixReplay.Recording.t()} | {:error, term()}

Completes and saves the buffered recording, retrying the save until it succeeds or attempts run out. Returns the saved recording.