Spandex.Decorators (Spandex v3.1.0) View Source

Provides a way of annotating functions to be traced.

Span function decorators take an optional argument which is the attributes to update the span with. One of those attributes can be the :tracer in case you want to override the default tracer (e.g., in case you want to use multiple tracers).

IMPORTANT If you define multiple clauses for a function, you'll have to decorate all of the ones you want to span.

Note: Decorators don't magically do everything. It often makes a lot of sense to use Tracer.update_span from within your function to add details that are only available inside that same function.

defmodule Foo do
  use Spandex.Decorators

  @decorate trace()
  def bar(a) do
    a * 2
  end

  @decorate trace(service: "ecto", type: "sql")
  def databaz(a) do
    a * 3
  end
end

Link to this section Summary

Link to this section Functions