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

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

metadata()

@type metadata() :: %{required(atom()) => term()}

t()

@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

ets_key(query_span)

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

Returns a key used for storage in ets.

fail(span, duration, error)

@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.

finish(span, duration, metadata)

@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.

new(query_id, ctx, type, start_time)

@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).