Created
September 16, 2015 09:37
-
-
Save benhartley/febdb500bb707d987609 to your computer and use it in GitHub Desktop.
New Relic examples
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
// Some of this is pseudo-code / redacted... | |
function get(routeName, params, res) { | |
... | |
return cache.get('hget', cacheKey, 'json') | |
.then(r => { | |
newRelic.endTransaction(); | |
return r; | |
}) | |
.catch(...); | |
} | |
module.exports = { | |
get: newRelic.createBackgroundTransaction('morph:get', get) | |
}; |
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
// Some of this is pseudo-code / redacted... | |
function route(routeName) { | |
return (req, res) => { | |
... | |
return res.format({ | |
'text/html': () => { | |
... | |
return cache.get('get', cacheKey) | |
.then(res.send.bind(res)) | |
.catch(...); | |
}, | |
'application/json': () => { | |
return module.method(args) | |
.then(res.send.bind(res)) | |
.catch((error) => { | |
... | |
return res.sendStatus(500); | |
}); | |
} | |
}); | |
}; | |
} | |
module.exports = { | |
route: newRelic.createTracer('cachedRoute', route) | |
}; | |
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
// Some of this is pseudo-code / redacted... | |
function get() { | |
return bluebird.props({ | |
key: val | |
}) | |
.then(orb => { | |
newRelic.endTransaction(); | |
return orb; | |
}); | |
} | |
module.exports = { | |
get: newRelic.createWebTransaction('orb:get', get) | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment