View Source OpentelemetryPhoenix (Opentelemetry Phoenix v2.0.0)

OpentelemetryPhoenix uses telemetry handlers to create OpenTelemetry spans.

Current events which are supported include endpoint start/stop, router start/stop, and router exceptions.

Supported options

  • :endpoint_prefix (list of atom/0) - The endpoint prefix in your endpoint. The default value is [:phoenix, :endpoint].

  • :adapter (:atom) - Required. The phoenix server adapter being used. The default value is :cowboy2.

  • :liveview (boolean/0) - Whether LiveView traces will be instrumented. The default value is true.

Adapters

  • cowboy2 - when using PlugCowboy as your adapter you must add :opentelemetry_cowboy to your project and pass adapter: :cowboy2 option when calling setup.
  • bandit - when using Bandit.PhoenixAdapter as your adapter you must add :opentelemetry_bandit to your project and pass adapter: :bandit option when calling setup

Usage

In your application start:

def start(_type, _args) do
  :opentelemetry_cowboy.setup()
  OpentelemetryPhoenix.setup(adapter: :cowboy2)

  children = [
    {Phoenix.PubSub, name: MyApp.PubSub},
    MyAppWeb.Endpoint
  ]

  opts = [strategy: :one_for_one, name: MyStore.Supervisor]
  Supervisor.start_link(children, opts)
end

Summary

Types

The phoenix server adapter being used. Required

The endpoint prefix in your endpoint. Defaults to [:phoenix, :endpoint]

Setup options

Types

@type adapter() :: {:adapter, :cowboy2 | :bandit}

The phoenix server adapter being used. Required

@type endpoint_prefix() :: {:endpoint_prefix, [atom()]}

The endpoint prefix in your endpoint. Defaults to [:phoenix, :endpoint]

@type opts() :: [endpoint_prefix() | adapter()]

Setup options

Functions

Link to this function

attach_liveview_handlers()

View Source
Link to this function

handle_liveview_event(list, arg2, meta, arg4)

View Source
@spec setup(opts()) :: :ok

Initializes and configures the telemetry handlers.