View Source Guesswork.Telemetry.QueryRun (Guesswork v0.4.4)

Represents a single 'run', or resolution, of a query.

Summary

Functions

Returns a key used for storage in ets.

Takes a query run and the duration of the run then completes the record by calculating and inserting the end_time and duration. duration is assumed to be :native unix times.

Takes a query run the duration and the error that failed the query, and then completes the record by calculating and inserting the end_time and duration. duration is assumed to be :native unix times.

Attempts to build a new query run entry using the needed ids and the start time provided by telemetry (assumes a :native unix time).

Types

@type t() :: %Guesswork.Telemetry.QueryRun{
  duration_ms: integer() | nil,
  end_time: DateTime.t() | nil,
  error: nil | term(),
  query_id: String.t(),
  run_id: String.t(),
  start_time: DateTime.t()
}

Functions

@spec ets_key(t()) :: {String.t(), String.t()}

Returns a key used for storage in ets.

@spec finish(t(), integer()) :: {:ok, t()} | {:error, atom()}

Takes a query run and the duration of the run then completes the record by calculating and inserting the end_time and duration. duration is assumed to be :native unix times.

Link to this function

finish(run, duration, error)

View Source
@spec finish(t(), integer(), term()) :: {:ok, t()} | {:error, atom()}

Takes a query run the duration and the error that failed the query, and then completes the record by calculating and inserting the end_time and duration. duration is assumed to be :native unix times.

Link to this function

new(query_id, run_id, start_time)

View Source
@spec new(String.t(), String.t(), integer()) :: {:ok, t()} | {:error, atom()}

Attempts to build a new query run entry using the needed ids and the start time provided by telemetry (assumes a :native unix time).