Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

env-newrelic

wilmoore36MIT0.3.1

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

newrelic, env, envc, environments, environment, 12factor

readme

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

changelog

Change Log

All notable changes to this project will be documented in this file.

0.3.0 - 2014-01-12

Added

  • default to enabled with option to disable.
  • application name defaults to package.name + - + process.env.NODE_ENV.
  • dropped env-allowed package.
  • better documentation.
  • tests.

0.1.0 - 2014-12-15

Added

  • extracted env-allowed and env-accessor modules.