Last active
March 31, 2020 15:01
-
-
Save ericmustin/839cf942a101743525c8e104010a5e65 to your computer and use it in GitHub Desktop.
example dd express hook
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
// npm install | |
const tracer = require('dd-trace').init({debug: false}) | |
tracer.use('express', { | |
hooks: { | |
request: (span, req, res) => { | |
console.log('express hook invoked') | |
span.setTag('hook_tag_key', 'hook_tag_value') | |
} | |
} | |
}) | |
const axios = require('axios') | |
const express = require('express') | |
const app = express() | |
const port = 5000 | |
app.get('*', function(req, res) { | |
console.log('responding') | |
res.send('Hello World!') | |
}) | |
app.listen(port, function() { | |
console.log(`listening on port ${port}!`) | |
}) | |
// $ curl localhost:5000 | |
// ## SAMPLE OUTPUT | |
// ok | |
// express hook |
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
{ | |
"name": "example_express_hook", | |
"version": "1.0.0", | |
"description": "", | |
"main": "example_express_hook.js", | |
"scripts": { | |
"start": "node example_express_hook.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"axios": "^0.19.1", | |
"dd-trace": "0.15.3", | |
"express": "^4.17.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example output
