PhoenixReplay.Session.TailSampling (PhoenixReplay v0.6.2)

Copy Markdown View Source

Decides whether a session is saved, from the :keep configuration.

A session matching errors: true or slower_than: ms is always saved. Otherwise a session without user interaction is discarded, and the :rate share of the rest is saved. See "Tail sampling" in PhoenixReplay.Config.

The decision only ever turns from discard to keep as events arrive: once a session is kept, later events cannot discard it. That lets PhoenixReplay.Session.Monitor start writing a running session to storage as soon as it is kept, observing its events incrementally with observe/3 and decision/3.

Summary

Types

What observe/3 has seen of a session's events so far.

Functions

Decides for a whole recording. See decision/3.

Decides from an observation, given a uniform draw in 0.0..1.0 for :rate.

An observation of no events.

Adds events to an observation.

Types

observation()

@type observation() :: %{
  event?: boolean(),
  params: non_neg_integer(),
  flagged?: boolean(),
  state_keys: MapSet.t(String.t())
}

What observe/3 has seen of a session's events so far.

reason()

@type reason() :: :not_interactive | :not_sampled

Functions

decide(recording, keep, draw \\ :rand.uniform())

@spec decide(PhoenixReplay.Recording.t(), PhoenixReplay.Config.keep(), float()) ::
  :keep | {:discard, reason()}

Decides for a whole recording. See decision/3.

decision(observation, keep, draw)

@spec decision(observation(), PhoenixReplay.Config.keep(), float()) ::
  :keep | {:discard, reason()}

Decides from an observation, given a uniform draw in 0.0..1.0 for :rate.

A session is interactive once it handled an event, navigated within the LiveView, that is, after more than its initial handle_params/3, had a form control changed, or changed client state it had reported before; see PhoenixReplay.Capture.State.

new()

@spec new() :: observation()

An observation of no events.

observe(observation, events, keep)

Adds events to an observation.