env-newrelic

0.3.1 • Public • Published

env-newrelic

Build Status NPM version NPM downloads LICENSE

Load newrelic in a 12-factor environment with sane defaults.

$ npm install env-newrelic --save

Why?

  1. You avoid writing and maintaining the following:

     if (process.env.NODE_ENV === 'production') require('newrelic');
    

    With the above methodology, you'll be forced to push code to change behavior that should be configuration driven. See The Twelve-Factor App page titled Store config in the environment.

  2. You avoid configuring a newrelic.js file for each app and start with sane defaults

     NEW_RELIC_HOME = Project Root Directory
     NEW_RELIC_ENABLED = true
     NEW_RELIC_APP_NAME = `package.name` + `-` + `process.env.NODE_ENV`
     NEW_RELIC_LOG_LEVEL = 'info'
    

How it works

Enable

Set the NEW_RELIC_LICENSE_KEY environment variable.

Disable

Set the NEW_RELIC_DISABLED environment variable to a truthy value (i.e. true, yes, 1, etc.).

Initialize
require('env-newrelic')()
# or
var newrelic = require('env-newrelic')()

NEW_RELIC_NO_CONFIG_FILE will be set to true if a newrelic.js file is found in your package root.

A list of more environment variables can be found in the documentation page Configuring Node.js with environment variables.

Overrides (newrelic.js)

While the environment variables make using a newrelic.js file optional, there may be situations where you need it. A list of more configuration parameters can be found in the documentation page Node.js agent configuration.

Example Configuration

For most apps, a newrelic.js file is not needed

.env
NEW_RELIC_LICENSE_KEY="…"
.env.test
NEW_RELIC_DISABLED=true

More Configuration

License

MIT

Package Sidebar

Install

npm i env-newrelic

Weekly Downloads

1

Version

0.3.1

License

MIT

Last publish

Collaborators

  • wilmoore