Skip to content

Instantly share code, notes, and snippets.

@ericmustin
Last active March 31, 2020 15:01
Show Gist options
  • Save ericmustin/839cf942a101743525c8e104010a5e65 to your computer and use it in GitHub Desktop.
Save ericmustin/839cf942a101743525c8e104010a5e65 to your computer and use it in GitHub Desktop.
example dd express hook
// 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
{
"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"
}
}
@ericmustin
Copy link
Author

example output
example_output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment