offworld-heapdumper
v0.1.1
Published
An NPM module that makes it easy to save heapdumps to an external storage service (starting with Amazon S3).
Downloads
4
Readme
offworld-heapdumper
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.
Installation
npm install offworld-heapdumper --save
Usage
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.
Let's start with a simple example
Uploading to S3 with minimal configuration
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.
Code
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"'
}
});
Other examples:
TODO: multi environment using KeyPrefix
Reference
See the reference for a full description of how to use this module.