View Source Spandex.Tracer behaviour (Spandex v3.2.0)

A module that can be used to build your own tracer.

Example:

defmodule MyApp.Tracer do
  use Spandex.Tracer, otp_app: :my_app
end

Link to this section Summary

Functions

A schema for the opts that a tracer accepts.

Link to this section Types

@type opts() :: Keyword.t() | :disabled
@type span_name() :: String.t()
@type tagged_tuple(arg) :: {:ok, arg} | {:error, term()}

Link to this section Callbacks

@callback configure(opts()) :: :ok
Link to this callback

continue_trace(span_name, trace_context, opts)

View Source
@callback continue_trace(
  span_name :: String.t(),
  trace_context :: Spandex.SpanContext.t(),
  opts()
) :: tagged_tuple(Spandex.Trace.t())
Link to this callback

continue_trace_from_span(span_name, span, opts)

View Source
@callback continue_trace_from_span(span_name(), span :: term(), opts()) ::
  tagged_tuple(Spandex.Trace.t())
@callback current_context(opts()) ::
  {:ok, Spandex.SpanContext.t()}
  | {:error, :disabled}
  | {:error, :no_span_context}
  | {:error, :no_trace_context}
  | {:error, [Optimal.error()]}
@callback current_span(opts()) :: nil | Spandex.Span.t()
@callback current_span_id(opts()) :: nil | Spandex.id()
@callback current_trace_id(opts()) :: nil | Spandex.id()
Link to this callback

distributed_context(t, opts)

View Source
@callback distributed_context(Plug.Conn.t(), opts()) :: tagged_tuple(map())
@callback finish_span(opts()) :: tagged_tuple(Spandex.Span.t())
@callback finish_trace(opts()) :: tagged_tuple(Spandex.Trace.t())
Link to this callback

inject_context(headers, opts)

View Source
@callback inject_context(Spandex.headers(), opts()) :: Spandex.headers()
@macrocallback span(span_name(), opts(), [{:do, Macro.t()}]) :: Macro.t()
Link to this callback

span_error(error, stacktrace, opts)

View Source
@callback span_error(error :: Exception.t(), stacktrace :: [term()], opts()) ::
  tagged_tuple(Spandex.Span.t())
Link to this callback

start_span(span_name, opts)

View Source
@callback start_span(span_name(), opts()) :: tagged_tuple(Spandex.Span.t())
Link to this callback

start_trace(span_name, opts)

View Source
@callback start_trace(span_name(), opts()) :: tagged_tuple(Spandex.Trace.t())
Link to this macrocallback

trace(span_name, opts, list)

View Source
@macrocallback trace(span_name(), opts(), [{:do, Macro.t()}]) :: Macro.t()
@callback update_span(opts()) :: tagged_tuple(Spandex.Span.t())
@callback update_top_span(opts()) :: tagged_tuple(Spandex.Span.t())

Link to this section Functions

A schema for the opts that a tracer accepts.


opts

Opts

  • adapter(:atom) Required: The third party adapter to use
  • disabled?(:boolean): Allows for wholesale disabling a tracer - Default: false
  • strategy(:atom): The storage and tracing strategy. Currently only supports local process dictionary. - Default: Spandex.Strategy.Pdict
  • sender(:atom): Once a trace is complete, it is sent using this module. Defaults to the default_sender/0 of the selected adapter
  • trace_key(:atom): Don't set manually. This option is passed automatically.

Span Creation

  • service(:atom) Required: The default service name to use for spans declared without a service
  • env(:string): A name used to identify the environment name, e.g prod or development
  • service_version(:string): The version of the service, used for tracking deployments.
  • services([{:keyword, :atom}, :keyword]): A mapping of service name to the default span types. - Default: []
  • completion_time(:integer)
  • error(:keyword)
  • http(:keyword)
  • id(:any)
  • name(:string)
  • parent_id(:any)
  • private(:keyword) - Default: []
  • resource([:atom, :string])
  • sql_query(:keyword)
  • start(:integer)
  • tags(:keyword) - Default: []
  • trace_id(:any)
  • type(:atom)

All tracer functions that take opts use this schema. This also accepts defaults for any value that can be given to a span.