OpentelemetryBreathalyzer (opentelemetry_breathalyzer v0.1.1)

Breathalyzer is an OpenTelemetry tracer for Absinthe.

  • Add it to your dependencies:
defp deps do
  [
    ...,
    {:opentelemetry_breathalyzer, "~> 0.1.0"}
  ]
end
  • Configure it:
config :opentelemetry_breathalyzer, :trace,
  execute_operation: [
    request_document: true,
    request_schema: true,
    request_selections: false,
    request_variables: true,
    request_complexity: false,
    response_errors: true,
    response_result: false,
    request_context: [[:current_user, :id]]
  ]
  • And setup it just before your application supervisor starts:
defmodule MyApplication do
  def start(_type, args) do
    opts = [strategy: :one_for_one, name: MySupervisor]
    OpentelemetryBreathalyzer.setup()
    Supervisor.start_link(children(args), opts)
end
  • You may also choose to start only a couple of handlers:

    defmodule MyApplication do
    def start(_type, args) do
      opts = [strategy: :one_for_one, name: MySupervisor]
      OpentelemetryBreathalyzer.setup(only: [:execute_operation, :execute_middleware]])
      Supervisor.start_link(children(args), opts)
    end
  • There you go. You should start seeing traces popping into your OpenTelemetry store.

Summary

Functions

Link to this function

attach_handler(type, config \\ %{})

Link to this function

detach_handler(atom)

Link to this function

setup(instrumentation_opts \\ [])