O11y.BaggageProcessor (O11y v0.2.11)

Adds any attributes stored in baggage in the current context to each span that is processed.

Configuration

In your project's config.exs (or runtime.exs or w/e):

config(:opentelemetry, :processors, [{O11y.BaggageProcessor, %{}}])

If there's already a processor configured, you can add this one to the list:

config(:opentelemetry, :processors, [
  {O11y.BaggageProcessor, %{}},
  otel_batch_processor: %{exporter: {:opentelemetry_exporter, %{}}}
])

Examples

iex> OpenTelemetry.Baggage.set("user_id", user.id)
...> # later in the request
iex> Tracer.with_span "checkout" do
...>   # this span will include the user_id attribute automatically
...> end

Summary

Types

attrs()

@type attrs() :: OpenTelemetry.attributes_map()

config()

@type config() :: any()

ctx()

@type ctx() :: :otel_ctx.t()

on_end_result()

@type on_end_result() ::
  true | :dropped | {:error, :invalid_span} | {:error, :no_export_buffer}

span()

@type span() :: OpenTelemetry.span()

Functions

force_flush(config)

@spec force_flush(config()) :: :ok | {:error, term()}

Callback implementation for :otel_span_processor.force_flush/1.

on_end(span, config)

@spec on_end(span(), config()) :: on_end_result()

Callback implementation for :otel_span_processor.on_end/2.

on_start(ctx, span, config)

@spec on_start(ctx(), span(), config()) :: span()

Callback implementation for :otel_span_processor.on_start/3.