An opinionated library for adding application tracing and metrics to a Phoenix application. Geometrics includes dependencies which hook into Phoenix and Ecto telemetry, adding support for LiveView as well as crash tracking.
This repo also contains informative guides to help you wrap your head around Application tracing concepts which can be notoriously confusing, especially in Elixir and Erlang. It is worth reading these before diving in.
Given this simple LiveView module in a Phoenix application:
defmodule GeometerTracingDemosWeb.PageLive do
use GeometerTracingDemosWeb, :live_view
alias GeometerTracingDemos.Repo
alias GeometerTracingDemos.SomeModel
require OpenTelemetry.Tracer
@impl true
def mount(_params, _session, socket) do
...
end
@impl true
def handle_event("create", %{"some_model" => form_attrs}, socket) do
# This is an example of adding a custom span to your application. All of the other application traces in the image
# below come by default after installing Geometrics without any other changes to source code.
OpenTelemetry.Tracer.with_span "My custom span" do
%SomeModel{}
|> SomeModel.changeset(form_attrs)
|> Repo.insert()
end
{:noreply, socket}
end
end
You can see an application trace that extends throughout an entire live view session.
(Note that the trace shown here is from the Honeycomb.io UI, but should carry over to any Application tracing service)
- To distill knowledge gleaned from dissecting the somewhat overwhelming OpenTelemetry/observability ecosystem into an easily consumed set of guides.
- To provide Phoenix LiveView observability, which has not yet been included into OpenTelemetry the way that Phoenix and Ecto have.
- To generally make it easier to get started with observing your Phoenix application
For further reading, see the guides.
External references: