Created
November 2, 2017 19:09
-
-
Save teebu/0a230908ae5ac0824e115ac8a6dae237 to your computer and use it in GitHub Desktop.
sample raven event logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const async = require('async'); | |
const download = require('download'); | |
const fs = require('fs-extra'); | |
const RavenLambdaWrapper = require('serverless-sentry-lib'); | |
const Raven = require('raven') | |
// Wrap handler for automated error and exception logging | |
const ravenConfig = { | |
filterLocal: false, | |
captureErrors: true, // Don't log error responses from the Lambda ... | |
captureUnhandledRejections: true, // but keep unhandled exception logging, ... | |
captureMemoryWarnings: false, // memory warnings ... | |
captureTimeoutWarnings: false, // and timeout warnings enabled. | |
ravenClient: Raven | |
}; | |
module.exports.handler = RavenLambdaWrapper.handler(ravenConfig, (event, context, callback) => { | |
// your Lambda Functions Handler code goes here... | |
console.log('event %j', event) | |
//somethingElse() // <= event in sentry | |
var option = event; | |
something(option, callback); | |
}); | |
function something(options, callback){ | |
async.series([ | |
function (callback) { // download | |
console.log('downloading', options.file) | |
download(options.file).then(data => { // <= CULPRIT | |
fs.writeFileSync('/tmp/flip.jpg', data); | |
return callback() | |
}).catch(e => callback(e)) | |
}, | |
function (callback) { // throw an error | |
// throw an error | |
//somethingElse() // <= no event in sentry | |
return callback(); | |
}], function (err, res) { | |
if (err) { | |
console.log('ERR:', err) | |
return callback(err) | |
} | |
return callback('error returned') // <= no event in sentry | |
//return callback(err, 'done') | |
}); | |
} | |
function somethingElse(){ | |
console.log(a) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"file" : "https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/flip.jpg", | |
"nothing": "just text" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment