Node.js

Installation

The installation of the Instana Node.js sensor is a simple two step process. First, install the instana-nodejs-sensor package in your application via:

npm install --save instana-nodejs-sensor

Now that the sensor is installed, it needs to be activated from within the application. Do this by requiring and initializing it as the first statement in your application. Please take care that this is the first statement as the sensor will otherwise not be able to access certain information.

require('instana-nodejs-sensor')();

The code shown above initializes the sensor with default configuration options. Refer to the CONFIGURATION.md file for a list of valid configuration options.

Supported Versions

Metrics, configuration data and manual tracing is supported in versions 4.0.0 and all above

Automatic tracing is supported in Node.js versions ^4.5 || ^5.10 || ^6 || ^7 || ^8.2.1 || ^9.1.0 || ^10.4.0, i.e.

  • 4.5 and above
  • 5.10 and above
  • 6.0.0 and above
  • 7.0.0 and above
  • 8.2.1 and above
  • 9.1.0 and above
  • 10.4.0 and above
HTTP
HTTP(s) servers
HTTP(s) clients
Express error handling & path templates
Fastify path templates
Databases
Elasticsearch
MongoDB
Mongoose
MySQL
MSSQL
Postgres
Redis
ioredis
Messaging
kafka-node
RabbitMQ/amqplib
Logging
Bunyan
Pino
Winston
Async
Timers
Native Promises
Bluebird Promises

Sensor Data Collection

Tracked Configuration Metrics
Runtime Versions GC Activity
Deployed Apps Memory Usage
Name Heap Spaces
Version Event Loop
Description HTTP Servers - Request/Response Times
Arguments Health check status and time of last status change
Dependencies
HTTP Servers Config
Health checks (via admin-plugin-healthcheck )  

Health Signatures

  • Garbage Collection Activity
  • Latency
  • Calls
  • Errors
  • Failing health checks (see Health Check Support below)

Health check support

The Instana Node.js sensor will conduct custom health checks and execute them every ten seconds. If the checks fail for at least 30 seconds, an issue will be raised to inform the user.

Health checks are gathered from installed admin-plugin-healthcheck modules.

health check

Health checks listed in the Node.js dashboard.

issue

Issue raised about failing health checks.

Tracing

Mode

OpenTracing

To instantiate the Node.js OpenTracing tracer:

const instana = require('instana-nodejs-sensor');

// Always initialize the sensor as the first module inside the application.
instana({
  tracing: {
    enabled: true
  }
});

const opentracing = require('opentracing');

// optionally use the opentracing provided singleton tracer wrapper
opentracing.initGlobalTracer(instana.opentracing.createTracer());

// retrieve the tracer instance from the opentracing tracer wrapper
const tracer = opentracing.globalTracer();

See https://github.com/instana/nodejs-sensor#opentracing for details.