View Source Ash.Tracer behaviour (ash v3.4.45)

A behaviour for implementing tracing for an Ash application.

Summary

Types

metadata()

@type metadata() :: %{
  domain: nil | module(),
  resource: nil | module(),
  actor: term(),
  tenant: term(),
  action: atom(),
  authorize?: boolean()
}

span_type()

@type span_type() ::
  :action
  | :changeset
  | :query
  | :flow
  | :calculate
  | :request_step
  | :change
  | :validation
  | :preparation
  | :custom_flow_step
  | :custom
  | :before_transaction
  | :before_action
  | :after_transaction
  | :after_action
  | {:custom, atom()}

t()

@type t() :: module()

Callbacks

get_span_context()

@callback get_span_context() :: term()

set_error(t)

(optional)
@callback set_error(Exception.t()) :: :ok

set_error(t, t)

(optional)
@callback set_error(Exception.t(), Keyword.t()) :: :ok

set_handled_error(t, t)

(optional)
@callback set_handled_error(Exception.t(), Keyword.t()) :: :ok

set_metadata(span_type, metadata)

@callback set_metadata(span_type(), metadata()) :: :ok

Set metadata for the current span.

This may be called multiple times per span, and should ideally merge with previous metadata.

set_span_context(term)

@callback set_span_context(term()) :: :ok

start_span(span_type, name)

@callback start_span(span_type(), name :: String.t()) :: :ok

stop_span()

@callback stop_span() :: :ok

trace_type?(atom)

(optional)
@callback trace_type?(atom()) :: boolean()

Functions

get_span_context(tracer)

set_error(tracers, error)

set_error(tracers, error, opts)

set_handled_error(tracers, error, opts)

set_metadata(tracers, type, metadata)

set_span_context(tracer, context)

span(type, name, tracer, block_opts \\ [])

(macro)

start_span(tracers, type, name)

stop_span(tracers)

telemetry_span(name, metadata, opts \\ [], block_opts)

(macro)

trace_type?(tracer, type)