Juggernaut.Telemetry (Juggernaut v0.4.0)

Copy Markdown View Source

The :telemetry events Juggernaut emits. Names and metadata keys are a public API: a rename is a breaking change.

EventMeasurementsMetadata
[:juggernaut, :run, :start | :stop | :exception]duration on stop (native)run_id, lane, scope; stop adds verdict, exit_code, counts
[:juggernaut, :phase, :start | :stop | :exception]durationrun_id, phase
[:juggernaut, :mutant, :stop]duration (native), testsrun_id, mutant_id, operator, status, kill_kind, selection, worker, reused?
[:juggernaut, :worker, :up | :recycle | :down]duration (native)run_id, worker, reason
[:juggernaut, :cache, :lookup]hits, misses, recorded_msrun_id

Spans use :telemetry.span/3, so start carries monotonic_time and system_time, and a telemetry_span_context pairs start with stop. Stop metadata always includes the start metadata. Mutant events are emitted by the controller, never by a worker node (a dying worker emits nothing).

Handlers run in the emitting process: attach cheap ones. attach_forwarder/2 sends every event to a process as {:juggernaut_telemetry, event, measurements, metadata}.

Summary

Functions

Forwards every Juggernaut event to pid as {:juggernaut_telemetry, event, measurements, metadata}.

Emits the result-cache lookup counts of a run.

Detaches a handler attached with attach_forwarder/2.

Every event name Juggernaut emits.

Emits the outcome of one mutant. info holds mutant_id, operator, status, kill_kind, selection, worker, reused?, duration_ms and tests (the number of tests run).

Runs fun inside a phase span and returns {result, duration_ms}.

Runs fun inside the run span. meta needs run_id, lane and scope; fun returns {result, stop_meta} (usually verdict, exit_code, counts). Returns result.

Emits a worker event: :up (with its boot time), :recycle or :down.

Functions

attach_forwarder(handler_id, pid)

@spec attach_forwarder(term(), pid()) :: :ok | {:error, :already_exists}

Forwards every Juggernaut event to pid as {:juggernaut_telemetry, event, measurements, metadata}.

cache_lookup(run_id, measurements)

@spec cache_lookup(String.t(), %{
  hits: non_neg_integer(),
  misses: non_neg_integer(),
  recorded_ms: non_neg_integer()
}) :: :ok

Emits the result-cache lookup counts of a run.

detach(handler_id)

@spec detach(term()) :: :ok | {:error, :not_found}

Detaches a handler attached with attach_forwarder/2.

events()

@spec events() :: [[atom()]]

Every event name Juggernaut emits.

mutant_stop(run_id, info)

@spec mutant_stop(String.t(), map()) :: :ok

Emits the outcome of one mutant. info holds mutant_id, operator, status, kill_kind, selection, worker, reused?, duration_ms and tests (the number of tests run).

span_phase(run_id, phase, fun)

@spec span_phase(String.t(), Juggernaut.Phase.name(), (-> term())) ::
  {term(), non_neg_integer()}

Runs fun inside a phase span and returns {result, duration_ms}.

span_run(meta, fun)

@spec span_run(map(), (-> {term(), map()})) :: term()

Runs fun inside the run span. meta needs run_id, lane and scope; fun returns {result, stop_meta} (usually verdict, exit_code, counts). Returns result.

worker(event, run_id, worker, reason, duration_ms)

@spec worker(
  :up | :recycle | :down,
  String.t(),
  non_neg_integer() | :boot,
  String.t() | nil,
  non_neg_integer()
) :: :ok

Emits a worker event: :up (with its boot time), :recycle or :down.