Phoenix
Send distributed traces to Last9 from an Phoenix app using OpenTelemetry
Phoenix is a web framework for the Elixir programming language. This comprehensive guide will help you instrument your Phoenix application with OpenTelemetry, seamlessly sending the traces to Last9. You can also check out the example application on GitHub↗.
Pre-requisites
-
You have a Phoenix application.
-
You have signed up for Last9, created a cluster, and obtained the following OTLP credentials:
-
endpoint
-https://otlp.last9.io
-
auth_header
- Obtain it from the Last9 dashboard.
-
Install OpenTelemetry packages
To perform the instrumentation, add the following packages to the mix.exs
file:
Now, run the following command to install the dependencies:
Setup instrumentation using OpenTelemetry
Add the necessary environment variables that can be obtained from the Last9 cluster’s write endpoint section details.
Next, in config/config.exs, add the following configuration:
Also, add the following in your endpoint.ex
file:
This is require by the opentelemetry_phoenix
package to trace the Phoenix requests.
Visualize the traces in Last9
Once the application runs with the above code, it will start pushing traces to Last9. You can see the result in action by looking at the APM dashboard in Last9.
Troubleshooting
Please get in touch with us on Discord or Email if you have any questions.