npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@envelop/newrelic

v10.1.0

Published

Instrument your GraphQL application with New Relic reporting. Take advantage of Distributed tracing to monitor performance and errors whilst ultimately getting to the root cause of issues.

Readme

@envelop/newrelic

Instrument your GraphQL application with New Relic reporting. Take advantage of Distributed tracing to monitor performance and errors whilst ultimately getting to the root cause of issues.

Below are some screenshots to show how tracking looks like in New Relic, in these examples all plugin options were set to true.

Error tracking, operation and resolver views: newrelic_error_operation_screenshot newrelic_error_resolver_screenshot

Successful operation tracking, operation plus root-field and sub-field resolvers: newrelic_successful_operation_screenshot newrelic_successful_root-field_resolver_screenshot newrelic_successful_sub-field_resolver_screenshot

Getting Started

  1. Install dependencies
  2. Configure the New Relic Agent
  3. Setup the New Relic Envelop plugin

Installation

This plugin expects the Node.js agent, newrelic npm package, to be installed in your application.

yarn add newrelic @envelop/newrelic

Basic usage Example

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useNewRelic } from '@envelop/newrelic'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useNewRelic({
      includeOperationDocument: true, // default `false`. When set to `true`, includes the GraphQL document defining the operations and fragments
      includeExecuteVariables: false, // default `false`. When set to `true`, includes all the operation variables with their values
      includeRawResult: false, // default: `false`. When set to `true`, includes the execution result
      trackResolvers: true, // default `false`. When set to `true`, track resolvers as segments to monitor their performance
      includeResolverArgs: false, // default `false`. When set to `true`, includes all the arguments passed to resolvers with their values
      rootFieldsNaming: true, // default `false`. When set to `true` append the names of operation root fields to the transaction name
      skipError: error => {
        return true // a function that allows you to skip reporting a given error to NewRelic. By default custom `EnvelopError`s will be skipped
      },
      extractOperationName: context => context.request.body.customOperationName // Allows to set a custom operation name to be used as transaction name and attribute
    })
  ]
})

Note: Transaction and segment/span timings may be affected by other plugins used. In order to get more accurate tracking, it is recommended to add the New Relic plugin last.

Advanced usage

The plugin allows you to keep control over the variables and arguments that are tracked in New Relic. In addition to the basic true/false boolean value, includeExecuteVariables and includeResolverArgs also accept a RegEx pattern. This allows you to implement white and black listing of properties to be tracked in New Relic.

This is particularly useful if you have properties coming through variables and arguments that are useful for debugging, but you don't want to leak users' data (such as PII). Below is a quick example of how you can use RegEx to set up white/black listing functionalities.

useNewRelic({
  includeExecuteVariables: /client|application/i, // whitelist, track only variables whose name contains "client" or "application" (e.g. clientName, applicationId, xApplicationId)
  trackResolvers: true, // track resolvers, since we also want to track resolvers' arguments
  includeResolverArgs: /^(?!name|email|password).*/i, // blacklist, track all arguments whose name does not match 'name', 'email' nor 'password'
}),

Obviously, the ones above are just a couple of examples, but clearly you have endless options to use any RegEx pattern to filter the variables and arguments in the way that best work for you.

Be aware that the only way to filter variables and arguments is to loop through them, so there is an O(n) cost when filtering, where n is the number of variables sent to the operation (when tracking execute variables), or the number of arguments passed to resolvers (when tracking resolvers arguments).

Agent Configuration

For full details about New Relic Agent configuration, we recommend reading New Relic's official Node.js agent configuration documentation.

The main methods to configure the New Relic Agent is through:

  • The newrelic.js file [or]
  • The environment variables

If you choose to use the newrelic.js file, then you need this file located in the root of your application. You can look here for a basic example of what this file can look like.

If you choose to configure the New Relic Agent through environment variables, then you can follow your preferred strategy to make sure the variables are set and available when your application starts. The variables are the same you can set in newrelic.js file, you just need to know that they need to start with NEW_RELIC_, obviously, the variables name must be fully uppercase.

The two variables that are always required are:

| Description | newrelic.js | Environment variable | | ---------------- | ---------------------------------------- | ----------------------------------------------- | | Application name | app_name: ['MyAppName'] | NEW_RELIC_APP_NAME=MyAppName | | License key | license_key: '40HexadecimalCharacters' | NEW_RELIC_LICENSE_KEY=40HexadecimalCharacters |

Other variables that are popularly used are:

| Description | newrelic.js | Environment variable | | --------------------------- | ---------------------------------------- | -------------------------------------------- | | Enable distributed tracing | distributed_tracing: { enabled: true } | NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true | | Logging level | logging: { level: 'info' } | NEW_RELIC_LOG_LEVEL=info | | Capture all request headers | allow_all_headers: true | NEW_RELIC_ALLOW_ALL_HEADERS=true | | Enable error collection | error_collector: { enabled: true } | NEW_RELIC_ERROR_COLLECTOR_ENABLED=true |

Finally, here is also a reference of all the configuration variables you can include in your newrelic.js file, or translate into the env variables equivalent.