View Source OpentelemetryEcto (opentelemetry_ecto v1.2.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.

Summary

Functions

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

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).
  • :additional_attributes - additional attributes to include in the span. If there are conflits with default provided attributes, the ones provided with this config will have precedence.
  • :db_statement - :disabled (default) | :enabled | fun Whether or not to include db statements. Optionally provide a function that takes a query string and returns a sanitized version of it. This is useful for removing sensitive information from the query string. Unless this option is :enabled or a function, query statements will not be recorded on spans.