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

Represents a span within a query run.

Summary

Functions

Returns a key used for storage in ets.

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

Takes a query span, the duration of the span, and the final metadata, 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 id, context, type, and the start time provided by telemetry (assumes a :native unix time).

Types

@type metadata() :: %{required(atom()) => term()}
@type t() :: %Guesswork.Telemetry.QuerySpan{
  ctx: term(),
  duration_ms: integer() | nil,
  end_time: DateTime.t() | nil,
  error: nil | term(),
  metadata: metadata() | nil,
  query_id: String.t(),
  start_time: DateTime.t(),
  type: atom()
}

Functions

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

Returns a key used for storage in ets.

Link to this function

fail(span, duration, error)

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

Takes a query span, the duration of the span, and the final error, 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(span, duration, metadata)

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

Takes a query span, the duration of the span, and the final metadata, 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, ctx, type, start_time)

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

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