Skip to content

newrelic-experimental/new-relic-rails-7-demo

New Relic Rails 7 on Render Demo Application

New Relic Experimental header

GitHub forks GitHub stars GitHub watchers

GitHub last commit

GitHub issues GitHub issues closed GitHub pull requests GitHub pull requests closed

Contributor Covenant License

Learn how to integrate the New Relix Ruby Agent into your Rails 7 web application and deploy it to Render.

Read the full blog post with step-by-step instructions on the New Relic blog.

This is a fully functioning web application running on Rails that incorporates the New Relic Ruby agent to send telemetry data to the New Relic One dashboard. You can fork this repository to start building your own Rails app instrumented with New Relic, or copy and paste the relevant sections from it and add it to your own code.

Requirements

This app was built with Ruby v3.1 and Rails v7.0.

Installation

Once you clone or fork the repository, first change into the directory and execute the following commands in your terminal:

$ bundle install
$ bundle exec rails db:prepare

Lastly, rename the .env.sample file to .env.

Usage

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 Ruby agent can be found inside the config/newrelic.yml file. You can customize the name that will appear for your application in the New Relic dashboard by changing the app_name setting:

common: &default_settings
  license_key: <%= ENV.fetch("NEW_RELIC_LICENSE_KEY") %>
  app_name: nr-demo-rails-7

Once you have done that, you can start your app locally by running bundle exec rails s from the command line and navigate to localhost:3000 in your web browser.

Deploying to Render

To deploy to Render follow these steps:

  1. Create a free Render account
  2. Create a Render blueprint
  3. Set the value of the RAILS_SECRET_KEY to the contents of your config/master.key in the deploy window and click Approve
  4. Set the value of the NEW_RELIC_LICENSE_KEY environment variable in the app settings on Render to the value in your .env file

That's it. You app will live on your #{appname}.onrender.com URL as soon as the build finishes.

Support

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.

Contributing

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.

License

This project is licensed under the Apache 2.0 License.