Opencensus.Trace (opencensus_elixir v0.5.0)

Macros to help Elixir programmers use OpenCensus tracing.

Link to this section Summary

Functions

Drop-in replacement for Task.async/1 that propagates the process' span context.

Drop-in replacement for Task.async/3 that propagates the process' span context.

Drop-in replacement for Task.await/2.

Wrap the given block in a child span with the given label/name and optional attributes.

Link to this section Functions

@spec async((() -> any())) :: Task.t()

Drop-in replacement for Task.async/1 that propagates the process' span context.

Does NOT start a new span for what's inside. Consider with_child_span/3.

Link to this function

async(module, function_name, args)

@spec async(module(), atom(), [term()]) :: Task.t()

Drop-in replacement for Task.async/3 that propagates the process' span context.

Does NOT start a new span for what's inside. Consider with_child_span/3.

Link to this function

await(task, timeout \\ 5000)

@spec await(Task.t(), :infinity | pos_integer()) :: term()

Drop-in replacement for Task.await/2.

Link to this macro

with_child_span(label, attributes \\ quote do %{} end, list)

(macro)

Wrap the given block in a child span with the given label/name and optional attributes.

Sets Logger.metadata/0 with Opencensus.Logger.set_logger_metadata/0 after changing the span context tracked in the process dictionary.

No attributes:

with_child_span "child_span" do
  :do_something
end

with_child_span "child_span", %{} do
  :do_something
end

Custom attributes:

with_child_span "child_span", [:module, :function, %{"custom_id" => "xxx"}] do
  :do_something
end

Automatic insertion of the module, file, line, or function:

with_child_span "child_span", [:module, :function, %{}] do
  :do_something
end

Collapsing multiple attribute maps (last wins):

with_child_span "child_span", [:function, %{"a" => "b", "c" => "d"}, %{"c" => "e"}] do
  :do_something
end