Nodetime

This add-on is operated by APPDYNAMICS INC.

Performance profiler and monitor for Node.js

Nodetime

Last Updated: 14 March 2014

Table of Contents

Nodetime is an add-on for all-round application performance management for Node.js, including server monitoring, database monitoring, transaction, CPU and memory profiling, alerting and more.

Adding performance monitoring and profiling to an application is essential for faster performance problem identification and localization, performance regression prevention, analysis and optimization. Not otherwise available, runtime insights of an application’s real-time and historical behaviour give developers the necessary control and visibility.

Nodetime’s agent library runs within the Node.js application and securely sends measurements and profiling data to Nodetime’s server.

Provisioning the add-on

Nodetime can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:add nodetime
-----> Adding nodetime to sharp-mountain-4005... done, v18 (free)

Once Nodetime has been added a NODETIME_ACCOUNT_KEY setting will be available in the app configuration and will contain the account key used to configure the Nodetime’s agent to access the newly provisioned Nodetime service instance. This can be confirmed using the heroku config:get command.

$ heroku config:get NODETIME_ACCOUNT_KEY
8151325dcdbae9e0ff95f9f9658432dbedfdb209

After installing Nodetime the application should be configured to fully integrate with the add-on.

Using with Node.js

Add the nodetime package to the package.json file.

Node.js applications will need to add the following code snippet into the main JavaScript module of your application, e.g. web.js or server.js, before all other require statements.

if(process.env.NODETIME_ACCOUNT_KEY) {
  require('nodetime').profile({
    accountKey: process.env.NODETIME_ACCOUNT_KEY,
    appName: 'My Application Name' // optional
  });
}

appName is used to logically differentiate applications, i.e. group dynos of the same process type. In case if Heroku application has several commands defined in the Procfile, e.g. web and worker, it is recommended to use different application names for each of them. Otherwise, the data from different types of processes may be aggregated inconsistently within a single Dashboard.

Monitoring & Logging

In case of problems with the Nodetime agent library, its activity can be observed within the Heroku log-stream by adding debug:true flag to profile() call beforehand.

$ heroku logs -t | grep 'nodetime'

Local Setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Though less portable it’s also possible to set local environment variables using export NODETIME_ACCOUNT_KEY=value.

Use Foreman to configure, run and manage process types specified in your app’s Procfile. Foreman reads configuration variables from an .env file. Use the following command to add the NODETIME_ACCOUNT_KEY values retrieved from heroku config to .env.

$ heroku config -s | grep NODETIME_ACCOUNT_KEY >> .env
$ more .env

Consider specifying a different appName in Nodetime’s configuration for local, development or staging servers in order to avoid data inconsistency.

Dashboard

For more information about the features available within the Nodetime dashboard please see the docs at nodetime.com/docs.

The Nodetime dashboard allows you to see multiple real-time and historical metrics from your application and databases, profile transactions, CPU usage and memory, and set up threshold alerts.

The dashboard can be accessed via the CLI:

$ heroku addons:open nodetime
Opening nodetime for sharp-mountain-4005…

or by visiting the Heroku apps web interface and selecting the application in question. Select Nodetime from the Add-ons menu.

Troubleshooting

If you don’t see any requests and operations in the transaction profiler, even though your application is receiving requests then 1) check if the profile() call is added before any other require statements. 2) add debug:true flag to profile() call and check the logs for possible errors by Nodetime’s agent library.

Migrating between plans

Application owners should carefully manage the migration timing to ensure proper application function during the migration process.

Nodetime offers several plans: Small, Medium, Large and Extra Large. All plans have the same functionality, except the maximum number of agents allowed to send data to Nodetime. There is normally one agent per dyno for an application / process type, which uses Nodetime. In cases when Node’s cluster module is used, number of agents may be more than one per dyno.

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade nodetime:medium
-----> Upgrading nodetime:pro to sharp-mountain-4005... done, v18 ($49/mo)
       Your plan has been updated to: nodetime:medium

Removing the add-on

Nodetime can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:remove nodetime
-----> Removing nodetime from sharp-mountain-4005... done, v20 (free)

Support

All Nodetime support and runtime issues should be submitted via one of the Heroku Support channels. Any non-support related issues or product feedback is welcome at Nodetime Support.