Created
July 29, 2015 10:17
-
-
Save hardware/3010353afe9b5165e95a to your computer and use it in GitHub Desktop.
This file contains 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
// cron.js | |
// [...] | |
if( newRelicEvents.length > 0 ) | |
newrelic.submitEvents( newRelicEvents, next ); | |
res.send('PROCESSING REQUESTS COMPLETED !'); | |
// [...] | |
---------------------------------------------------------------------------------------------------------------- | |
// newrelicApi.js | |
// [...] | |
exports.submitEvents = function( events, next ) { | |
request({ | |
uri:'https://insights-collector.newrelic.com/v1/accounts/' + process.env.NEW_RELIC_ACCOUNT + '/events', | |
method:'POST', | |
headers: { | |
'X-Insert-Key': process.env.NEW_RELIC_API_KEY, | |
'Content-Type': 'application/json' | |
}, | |
json:true, | |
body:events | |
}, function( err, response, body ) { | |
if( err || response.statusCode != 200 ) { | |
next( new Error("NEWRELIC API - Submitting events failed") ); | |
return; | |
} | |
}); | |
}; | |
// [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment