Skip to content

Instantly share code, notes, and snippets.

@elliotttf
Created June 22, 2017 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotttf/ac92dbe5061ac6023aa41ee42a8bfc2a to your computer and use it in GitHub Desktop.
Save elliotttf/ac92dbe5061ac6023aa41ee42a8bfc2a to your computer and use it in GitHub Desktop.
'use strict';
const { createBackgroundTransaction, endTransaction } = require('newrelic');
const fs = require('fs');
createBackgroundTransaction('fileProcessing', () => {
return new Promise((resolve, reject) => fs.readFile('/tmp/input.txt', (err, file) => {
if (err) {
return reject(err);
}
resolve(file);
}))
.then(file => {
// process file contents
})
.then(() => endTransaction())
.catch(() => endTransaction());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment