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?
OpenTelemetry is a vendor-neutral standard on how to collect telemetry data for applications and their supporting infrastructures. OpenTelemetry was created via the merger of OpenCensus and OpenTracing projects.
OpenTelemetry aims to standardize how you collect and send telemetry data to backend platforms: distributed tracing and OpenTelemetry metrics.
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.
Usage
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
: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
See the official documentation for the full list of supported options.
What is Uptrace?
Uptrace is an open source APM for OpenTelemetry that helps developers pinpoint failures and find performance bottlenecks. Uptrace can process billions of spans on a single server and allows to monitor your software at 10x lower cost.
You can get started with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.
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.