de84e7b275
These fields are required in `Oban.Job` |
||
---|---|---|
.. | ||
assets | ||
config | ||
lib | ||
priv | ||
test | ||
.env | ||
.formatter.exs | ||
.gitignore | ||
Dockerfile | ||
README.md | ||
docker-compose.yaml | ||
mix.exs | ||
mix.lock | ||
otel-collector-config.yaml |
README.md
Phoenix + Ecto OpenTelemetry Example
This is a example repository that demo how to setup OpenTelemetry for Phoenix application
with opentelemetry_phoenix
and opentelemetry_ecto
.
Here, we are using opentelemetry_exporter
to export the traces to
OpenTelemetry Collector. The collector in turn export the traces to Zipkin and
Jaeger respectively.
Additionally, we also include the OpenTelemetry Collector and
opentelemetry_exporter
configuration to
export the traces to external services like Honeycomb and
Lightstep. Do remember to update the .env
file to
include your crendentials if you're doing so.
Getting Stated
By default, we only configure our OpenTelemetry collector to export traces to the local Zipkin and Jaeger.
Assuming you already have Docker and Docker Compose installed:
-
Run
docker compose up -d
to start the Phoenix application, PostgreSQL, OpenTelemetry Collector, Zipkin and Jaeger. -
Run deps get and ecto setup:
mix deps.get, ecto.setup
-
Start phoenix
OTEL_SERVICE_NAME=demo iex -S mix phx.server
-
Browse to http://localhost:4000. Additionally, you can:
- Visit http://localhost:4000/posts to see how it works for Phoenix HTML
- Visit http://localhost:4000/users to see how it works for Phoenix LiveView
- Visit Zipkin at http://localhost:9411 and hit
Run Query
to look the the sample trace. - Visit Jaeger UI at http://localhost:16686, select
demo
under Service and clickFind Trace
to look at the sample trace. - Run
docker compose down
to destroy the created resources.
Different ways to export traces
In general, there are 2 ways you can export your OpenTelemetry traces.
-
Export to OpenTelemetry Collector, which can then be configured to export to external services.
Application --> OpenTelemetry Collector --> Zipkin |-----> Jaeger
-
Export directly to external services that accept OTLP protocol.
Application --> External Service
For exporting to external services, be sure to checkout their documentation first. For example: