MiregoElixirOtelAgent behaviour (mirego_elixir_otel_agent v0.2.0)

Copy Markdown View Source

Drop-in OpenTelemetry agent for Elixir applications.

See the README for the complete installation and configuration guide. The module documentation below describes the use API and callbacks.

use options

  • :ecto_prefixes — Ecto telemetry prefixes for baseline DB metrics (e.g. [[:my_app, :repo]]). Also passed to OpentelemetryEcto.setup/1 when :auto_instrument is true.
  • :baseline_metricstrue (default), false, or a keyword of groups: [vm: true, http: true, ecto: true, graphql: true] when Absinthe is loaded, otherwise graphql: false.
  • :auto_instrumenttrue (default) or false. When true, the agent attaches the built-in Phoenix, Ecto, Bandit/Cowboy, Absinthe, and Oban instrumentations automatically on start (when their modules are present and :phoenix_adapter matches the server adapter). Set to false if you want to call those yourself from on_start/0.

Summary

Callbacks

Optional callback returning app-specific Telemetry.Metrics definitions.

Optional callback invoked when the agent supervisor starts and the agent is enabled.

Callbacks

extra_metrics()

(optional)
@callback extra_metrics() :: [Telemetry.Metrics.t()]

Optional callback returning app-specific Telemetry.Metrics definitions.

Merged after the agent baseline metrics.

on_start()

(optional)
@callback on_start() :: :ok | any()

Optional callback invoked when the agent supervisor starts and the agent is enabled.

Use it for any additional one-shot setup that the automatic instrumentation does not cover. The built-in Phoenix, Ecto, server adapter, Absinthe, and Oban instrumentations are attached automatically unless :auto_instrument is false.

Functions

config()

See MiregoElixirOtelAgent.Config.resolve/0.

default_opts(opts)

Applies library defaults to use options.

Currently sets baseline_metrics: [graphql: true] when Absinthe is loaded in the host project, unless the user already supplied a :baseline_metrics value.

enabled?()

See MiregoElixirOtelAgent.Config.enabled?/0.