Learn how to integrate the New Relix Elixir Agent into your Phoenix web application.
This is a fully functioning web application running on Phoenix that incorporates the New Relic Elixir agent to send telemetry data to the New Relic One dashboard. You can fork this repository to start building your own Phoenix app instrumented with New Relic, or copy and paste the relevant sections from it and add it to your own code.
This app was built with Elixir v1.13.2 and Phoenix v1.6.6.
Once you clone or fork the repository, first change into the directory and execute the following commands in your terminal:
$ mix octo.create
$ mix.octo.migrate
Lastly, rename the .env.sample
file to .env
.
To use this app you must sign up for an account with New Relic. An account with New Relic is and will always be free. Once you have an account, create a new license key in the API keys section of the user settings, and copy the value to your .env
file's NEW_RELIC_LICENSE_KEY=
value.
The configuration for the New Relic Elixir agent can be found inside the config/config.exs
file. You can customize the name that will appear for your application in the New Relic dashboard by changing the app_name
setting:
config :new_relic_agent,
app_name: "nr_phoenix_demo",
license_key: System.get_env("NEW_RELIC_LICENSE_KEY")
Once you have done that, you can start your app locally by running mix phx.server
from the command line and
navigate to localhost:4000
in your web browser.
You can deploy the application directly from this GitHub repository by clicking on the Deploy to Heroku
button at the top of this README. Once you do that you still must set your New Relic License key in Heroku. You can either do so at the time you are initializing your application after you have the clicked the Deploy to Heroku
button above, or after from within the Heroku Dashboard.
After you have clicked the above Deploy to Heroku
button, you will see one option for the config vars
in the Heroku deployment settings. Add your New Relic License Key before clicking the final Deploy app
button. This will ensure your application is deployed to Heroku with your information.
Alternatively, you can do so from with your Heroku Dashboard's application settings by managing the config vars for your Phoenix app after deploying. You will need to add the environment variable: NEW_RELIC_LICENSE_KEY
.
New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub.
We encourage you to bring your experiences and questions to the Explorers Hub where our community members collaborate on solutions and new ideas.
We encourage your contributions to improve this Phoenix demo app! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
A note about vulnerabilities
As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.
This project is licensed under the Apache 2.0 License.