Skip to content

Instantly share code, notes, and snippets.

@ericmustin
Created January 8, 2020 16:34
Show Gist options
  • Save ericmustin/9625e2fb27a98bc7d0b9e144a73f048b to your computer and use it in GitHub Desktop.
Save ericmustin/9625e2fb27a98bc7d0b9e144a73f048b to your computer and use it in GitHub Desktop.
example request-promise distributed header id injection
Example app listening on port 5000!
Inject into carrier: {"x-datadog-trace-id":"4975767728554009637","x-datadog-parent-id":"4633592010209712543","x-datadog-sampling-priority":"1"}
const tracer = require('dd-trace').init({debug: true})
const rp = require('request-promise');
const express = require('express')
async function init(req, res) {
const response = await rp.get('http://www.google.com')
res.send('Hello World!')
}
const app = express()
const port = 5000
app.get('/', init)
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
{
"name": "node_tracing",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dd-trace": "^0.16.2",
"express": "^4.17.1",
"request": "^2.88.0",
"request-promise": "^4.2.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment