# node-newrelic **Repository Path**: mirrors_Unitech/node-newrelic ## Basic Information - **Project Name**: node-newrelic - **Description**: New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com. - **Primary Language**: Unknown - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-19 - **Last Updated**: 2026-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![npm status badge](https://nodei.co/npm/newrelic.png?stars=true&downloads=true)](https://nodei.co/npm/newrelic/) # New Relic for Node.js This package instruments your application for performance monitoring with [New Relic](http://newrelic.com). Make sure you have a [New Relic account](http://newrelic.com) before starting. To see all the features, such as slow transaction traces, you will need a [New Relic Pro](http://newrelic.com/application-monitoring/features) subscription (or equivalent). As with any instrumentation tool, please test before using in production. ## Table of contents * [Getting started](#getting-started) * [Security](#security) * [Configuration](#configuring-the-module) * [RUM / browser timings](#browser-timings-rum--real-user-monitoring) * [Transactions and request naming](#transactions-and-request-naming) * [Licensing](#license) * [Contributions](#contributions) * [Known issues](#known-issues) ## Getting started 1. [Install node](http://nodejs.org/#download). The agent runs on v0.8 and higher, but some features (e.g. error tracing) depend on features introduced in v0.10. Development work on this module is done with the latest non-development release of Node. 2. Verify your version of node came with a new enough version of npm using `npm -v`. We require version 1.4.28 or newer, and recommend using the latest release. Read more about [upgrading npm here](#upgrading-npm). 3. Install this module via `npm install newrelic` for the application you want to monitor. 4. Copy `newrelic.js` from `node_modules/newrelic` into the root directory of your application. 5. Edit `newrelic.js` and replace `license_key`'s value with the license key for your account. 6. Add `require('newrelic');` as the first line of the app's main module. If you wish to keep the configuration for the module separate from your application, the module will look for newrelic.js in the directory referenced by the environment variable `NEW_RELIC_HOME` if it's set. When you start your app, New Relic should start up with it and start reporting data that will appear within [the New Relic UI](https://rpm.newrelic.com/) after a few minutes. Because the agent minimizes the amount of bandwidth it consumes, it only reports data once a minute, so if you require the module in tests that take less than a minute to run, it won't have time to report data to New Relic. The module will write its log to a file named `newrelic_agent.log` in the application directory. If New Relic doesn't send data or crashes your app, the log can help New Relic determine what went wrong, so be sure to send it along with any bug reports or support requests. ### Upgrading npm If you're running on a version of npm before 1.4.28, or are interested in moving up to latest follow these steps: 1. Run `npm -v` to make sure you have npm installed and working. 2. If you are on linux/smartos/osx/*nix run `ls -l $(which npm)` and check to see if the file is owned by "root" or "admin". If so, prefix the next command with `sudo`. 3. Run `npm install -g npm@latest` to upgrade npm itself. **Warning**: An existing installation of npm can break if it is used to upgrade itself without root privileges while the npm executable is owned by root. ## Security We take security (and the protection of your and your users' privacy) very seriously. See [SECURITY.md](SECURITY.md) for details, but the brief version is that if you feel you've found a security issue, contact us at security@newrelic.com. ## Configuring the module The module can be tailored to your app's requirements, both from the server and via the newrelic.js configuration file you created. For complete details on what can be configured, refer to [`lib/config.default.js`](https://github.com/newrelic/node-newrelic/blob/master/lib/config.default.js), which documents the available variables and their default values. In addition, for those of you running in PaaS environments like Heroku or Microsoft Azure, all of the configuration variables in `newrelic.js` have counterparts that can be set via environment variables. You can mix and match variables in the configuration file and environment variables freely; environment variables take precedence. Here's the list of the most important variables and their values: * `NEW_RELIC_LICENSE_KEY`: Your New Relic license key. This is a required setting with no default value. * `NEW_RELIC_APP_NAME`: The name of this application, for reporting to New Relic's servers. This value can be also be a comma-delimited list of names. This is a required setting with no default value. (NOTE: as a convenience to Azure users, the module will use `APP_POOL_ID` as the application name if it's set, so you can use the name you chose for your Azure Web Server without setting it twice.) * `NEW_RELIC_NO_CONFIG_FILE`: Inhibit loading of the configuration file altogether. Use with care. This presumes that all important configuration will be available via environment variables, and some log messages assume that a config file exists. * `NEW_RELIC_HOME`: path to the directory in which you've placed newrelic.js. * `NEW_RELIC_USE_SSL`: Use SSL for communication with New Relic's servers. Enabled by default. * `NEW_RELIC_LOG`: Complete path to the New Relic agent log, including the filename. The agent will shut down the process if it can't create this file, and it creates the log file with the same umask of the process. Setting this to `stdout` will write all logging to stdout, and `stderr` will write all logging to stderr. * `NEW_RELIC_LOG_LEVEL`: Logging priority for the New Relic agent. Can be one of `error`, `warn`, `info`, `debug`, or `trace`. `debug` and `trace` are pretty chatty; unless you're helping New Relic figure out irregularities with the module, you're probably best off using `info` or higher. For completeness, here's the rest of the list: * `NEW_RELIC_ENABLED`: Whether or not the agent should run. Good for temporarily disabling the agent while debugging other issues with your code. It doesn't prevent the module from bootstrapping its instrumentation or setting up all its pieces, it just prevents it from starting up or connecting to New Relic's servers. Defaults to true. * `NEW_RELIC_ERROR_COLLECTOR_ENABLED`: Whether or not to trace errors within your application. Values are `true` or `false`. Defaults to true. * `NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERROR_CODES`: Comma-delimited list of HTTP status codes to ignore. Maybe you don't care if payment is required? Ignoring a status code means that the transaction is not renamed to match the code, and the request is not treated as an error by the error collector. Defaults to ignoring 404. * `NEW_RELIC_IGNORE_SERVER_CONFIGURATION`: Whether to ignore server-side configuration for this application. Defaults to false. * `NEW_RELIC_TRACER_ENABLED`: Whether to collect and submit slow transaction traces to New Relic. Values are `true` or `false`. Defaults to true. * `NEW_RELIC_TRACER_THRESHOLD`: Threshold of web transaction response time (in seconds) at which a transaction trace will count as slow and be sent to New Relic. Can also be set to `apdex_f`, at which point it will set the trace threshold to 4 times the current ApdexT. Defaults to `apdex_f`. * `NEW_RELIC_APDEX`: Set the initial Apdex tolerating / threshold value in seconds. This is more often than not set from the server. Defaults to 0.100. * `NEW_RELIC_CAPTURE_PARAMS`: Whether to capture request parameters on slow transaction or error traces. Defaults to false. * `NEW_RELIC_IGNORED_PARAMS`: Some parameters may contain sensitive values you don't want being sent out of your application. This setting is a comma-delimited list of names of parameters to ignore. Defaults to empty. * `NEW_RELIC_NAMING_RULES`: A list of comma-delimited JSON object literals: `NEW_RELIC_NAMING_RULES='{"pattern":"^t","name":"u"},{"pattern":"^u","name":"t"}'` See the section on request and transaction naming for details. Defaults to empty. * `NEW_RELIC_IGNORING_RULES`: A list of comma-delimited patterns: `NEW_RELIC_IGNORING_RULES='^/socket\.io/.*/xhr-polling,ignore_me'` Note that currently there is no way to escape commas in patterns. Defaults to empty. * `NEW_RELIC_TRACER_TOP_N`: Increase this number to increase the diversity of slow transaction traces sent to New Relic. Defaults to 1. See the description in `lib/config.default.js`, as this feature is exceedingly hard to summarize. * `NEW_RELIC_HOST`: Hostname for the New Relic collector. You shouldn't need to change this. * `NEW_RELIC_PORT`: Port number on which the New Relic collector will be listening. You shouldn't need to change this either. * `NEW_RELIC_PROXY_URL`: A fully-qualified URL to an http/https proxy. The proxy URL may include basic authentication. The use of `NEW_RELIC_PROXY_URL` overrides other proxy settings. * `NEW_RELIC_PROXY_HOST`: Proxy hostname * `NEW_RELIC_PROXY_PORT`: Proxy port. * `NEW_RELIC_PROXY_USER`: Proxy user name (basic auth only). * `NEW_RELIC_PROXY_PASS`: Proxy password. * `NEW_RELIC_DEBUG_METRICS`: Whether to collect internal supportability metrics for the agent. Don't mess with this unless New Relic asks you to. * `NEW_RELIC_DEBUG_TRACER`: Whether to dump traces of the transaction tracer's internal operation. It's unlikely to be informative unless you're a New Relic Node.js engineer and it has a significant performance cost, so use with care. * `NEW_RELIC_BROWSER_MONITOR_ENABLE`: Whether to generate browser timing (RUM) headers or not. * `NEW_RELIC_LABELS`: Sets the label names and values to associate with the application. The list is a semi-colon delimited list of colon-separated name and value pairs ## Browser timings (RUM / Real User Monitoring) New Relic's instrumentation can extend beyond your application into the client's browser. The `newrelic` module can generate `