An NPM module that makes it easy to save NodeJS heapdumps to an external storage service (starting with Amazon S3). Useful for troubleshooting memory issues on PaaS environments such as Heroku.
npm install offworld-heapdumper --save
At some point, there might be multiple Destinations
for your heapdump, but for now there is only Amazon S3. The
following examples will be using S3.
In this scenario, we push the heapdump to the S3 bucket of your choice with default settings, which are:
- An
ACL
ofprivate
- A name derived from the current time (UTC) i.e.
20150101_153454.heapdump
- S3 Authentication credentials taken from standard AWS SDK Configuration options.
var HeapdumpOffworld = require("offworld-heapdumper");
var S3Destination = HeapdumpOffworld.Destinations.S3;
var destination = new S3Destination({bucket:"hyacinth"});
var heapdumper = new HeapdumpOffworld(destination);
heapdumper.writeSnapshot(function(err, details) {
if (err) throw err;
//Since we're using S3 as the destination, the details parameter contains:
{
Location: 'https://bucketName.s3.amazonaws.com/filename.ext',
Bucket: 'bucketName',
Key: 'filename.ext',
ETag: '"bf2acbedf84207d696c8da7dbb205b9f-5"'
}
});
TODO: multi environment using KeyPrefix
See the reference for a full description of how to use this module.