InstrumentationDescriptor

Describes the configuration for an instrumentation. An instrumentation is what newrelic uses to wrap Node.js modules. In particular, a description details the name of the module, the path on disk to the module, and the hooks (onRequire and onError) to apply to the module.

Constructor

new InstrumentationDescriptor(params)

Parameters:
NameTypeDescription
paramsInstrumentationDescriptorParams

Members

TYPE_DATASTORE :string

Database module, such as the MongoDB or MySQL drivers.

Type:
  • string

TYPE_GENERIC :string

Utility/generic module.

Type:
  • string

TYPE_MESSAGE :string

Messaging module, such as AMQP.

Type:
  • string

TYPE_PROMISE :string

Promise module, such as Bluebird.

Type:
  • string

TYPE_TRACKING :string

Used to load supportability metrics on installed versions of packages that the Node.js agent does not instrument (e.g. OTEL instrumentation or top logging libraries).

Type:
  • string

TYPE_WEB_FRAMEWORK :string

Web server framework module, such as Express or Fastify.

Type:
  • string

absolutePath

The absolute path to the module to instrument. This should only be set when the module being instrumented does not reside in a node_modules directory; for example, when someone is instrumenting a module of their own through the public API.

The moduleName property still needs to be set to the simple name, i.e. the string passed to require, for instrumentation tracking purposes.

Note: this value takes precedence over moduleName.

instrumentationId

Identifier for the instrumentation. Used by the internal instrumentation tracker to distinguish between different instrumentations targeting the same module.

module :string

The name of the module being instrumented, i.e. the string used to require the module. This must map to a directory in lib/instrumentations which contains an nr-hooks.js file.

This takes precedence over moduleName.

Type:
  • string

moduleName :string

The name of the module being instrumented, i.e. the string used to require the module. This must map to a JavaScript file of the same name in the lib/instrumentations directory.

Type:
  • string

onError :InstrumentationOnError

Hook to invoke when the onRequire hook throws an error.

onRequire :InstrumentationOnRequire

Hook to invoke when the module is required. This is the actual implementation of the instrumentation.

resolvedName :string

The fully resolved path to the module, e.g. /opt/app/node_modules/foo. If the module is a core module, the special value . should be used.

Type:
  • string

shimName :string

Used when instrumenting a module to determine if a module has already been wrapped by a specific shim instance. It is used in conjunction with the shim.id value.

Type:
  • string

type :string|null

The type of the module being instrumented. See the static TYPE_ fields.

Type:
  • string | null