OpenTelemetryDecorator.trace
You're seeing just the function
trace
, go back to OpenTelemetryDecorator module for more information.
Link to this function
trace(span_name, opts \\ [], body, context)
Decorate a function to add an OpenTelemetry trace with a named span.
You can provide span attributes by specifying a list of variable names as atoms. This list can include:
- any variables (in the top level closure) available when the function exits,
- the result of the function by including the atom
:result
, - map/struct properties using nested lists of atoms.
defmodule MyApp.Worker do
use OpenTelemetryDecorator
@decorate trace("my_app.worker.do_work", include: [:arg1, [:arg2, :count], :total, :result])
def do_work(arg1, arg2) do
total = arg1.count + arg2.count
{:ok, total}
end
end
You can also provide a sampler that will override the globally configured one:
defmodule MyApp.Worker do
use OpenTelemetryDecorator
@sampler :ot_sampler.setup(:probability, %{probability: 0.5})
@decorate trace("my_app.worker.do_work", sampler: @sampler, include: [:arg1, :arg2, :result])
def do_work(arg1, arg2) do
total = arg1.count + arg2.count
{:ok, total}
end
end