View Source OpentelemetryPhoenix (Opentelemetry Phoenix v1.2.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 - The phoenix server adapter being used. The default value is nil.

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

If you are using PlugCowboy as your adapter you can add :opentelemetry_cowboy to your project and pass the :adapter option when calling setup. Setting this option will prevent a new span from being started and the existing cowboy span to be continued. This is the recommended setup for measuring accurate latencies.

Bandit.PhoenixAdapter is not currently supported.

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. Optional

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

Setup options

Types

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

The phoenix server adapter being used. Optional

@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.