View Source OpentelemetryEcto (opentelemetry_ecto v1.0.0)

Telemetry handler for creating OpenTelemetry Spans from Ecto query events. Any relation preloads, which are executed in parallel in separate tasks, will be linked to the span of the process that initiated the call. For example:

Tracer.with_span "parent span" do
  Repo.all(Query.from(User, preload: [:posts, :comments]))
end

this will create a span called "parent span" with three child spans for each query: users, posts, and comments.

Note

Due to limitations with how Ecto emits its telemetry, nested preloads are not represented as nested spans within a trace.

Link to this section Summary

Functions

Attaches the OpentelemetryEcto handler to your repo events. This should be called from your application behaviour on startup.

Link to this section Functions

Link to this function

setup(event_prefix, config \\ [])

View Source

Attaches the OpentelemetryEcto handler to your repo events. This should be called from your application behaviour on startup.

Example:

OpentelemetryEcto.setup([:blog, :repo])

You may also supply the following options in the second argument:

  • :time_unit - a time unit used to convert the values of query phase timings, defaults to :microsecond. See System.convert_time_unit/3

  • :span_prefix - the first part of the span name, as a String.t, defaults to the concatenation of the event name with periods, e.g. "blog.repo.query". This will always be followed with a colon and the source (the table name for SQL adapters).