View Source OpentelemetryPhoenix (Opentelemetry Phoenix v1.1.1)

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

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.

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

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

Link to this section Summary

Types

The phoenix server adapter being used. Optional

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

Setup options

Functions

Initializes and configures the telemetry handlers.

Link to this section 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

Link to this section Functions

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

Initializes and configures the telemetry handlers.