Monitor Elixir Phoenix with OpenTelemetry

OpenTelemetry Phoenix is an implementation of the OpenTelemetry specification for Phoenix Framework. It provides a set of libraries and tools for instrumenting Phoenix applications to collect telemetry data such as metrics, traces, and logs.

Otel Phoenix provides the ability to trace Phoenix web requests and to measure the performance and resource utilization of these requests. You can then analyze this information to understand how an application is handling web traffic and to identify performance bottlenecks and other issues.

What is OpenTelemetry?

OpenTelemetryopen in new window is a vendor-neutral standard on how to collect telemetry data for applications and their supporting infrastructures. OpenTelemetry was created by merging OpenCensus and OpenTracing projects.

OpenTelemetry aims to standardize how you collect and send telemetry data to backend platforms: distributed tracingopen in new window, logsopen in new window, and OpenTelemetry metricsopen in new window.

By using OpenTelemetry, developers gain valuable insight into the performance, behavior and dependencies of their applications, enabling them to optimize and troubleshoot their systems more effectively.

OpenTelemetry Phoenix

With OpenTelemetry Phoenix, developers can gain a deeper understanding of how their applications handle web requests. Then can use this information to improve the performance and reliability of their applications.

Otel Phoenix can help developers monitor and diagnose issues with their Phoenix-based applications, and it can provide valuable insights into the behavior of the applications in production.


To use OpenTelemetry Phoenix, you'll need to add the opentelemetry_phoenix library to your application's dependencies in the mix.exs file.

In your application start:

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

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

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

See the official documentationopen in new window for the full list of supported options.

What is Uptrace?

Uptrace is a DataDog alternativeopen in new window that supports distributed tracing, metrics, and logs. You can use it to monitor applications and troubleshoot issues.

Uptrace Overview

Uptrace comes with an intuitive query builder, rich dashboards, alerting rules with notifications, and integrations for most languages and frameworks.

Uptrace can process billions of spans and metrics on a single server and allows you to monitor your applications at 10x lower cost.

In just a few minutes, you can try Uptrace by visiting the cloud demoopen in new window (no login required) or running it locally with Dockeropen in new window. The source code is available on GitHubopen in new window.

What's next?

To get start with OpenTelemetry, see OpenTelemetry Elixir.

To collect more telemetry data from your Phoenix application, you'll need to instrument your code using the OpenTelemetry Phoenix API. This typically involves adding calls to the OpenTelemetry Phoenix library at key points in your code, such as when a request is received or when a database query is executed.

Last Updated: