Created
March 2, 2020 14:37
-
-
Save ericmustin/e6dcb7e6dbd576afc45def460fb00783 to your computer and use it in GitHub Desktop.
example node fetch distributed tracing
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
// cd into root of this directory | |
// npm install | |
// npm install -g http-echo-server | |
// new terminal window from run `http-echo-server` | |
// node index.js | |
// see output that server receives in output.txt | |
tracer = require('dd-trace').init() | |
const fetch = require('node-fetch'); | |
const testUrl = 'http://localhost:3000/hello' | |
fetch(testUrl) | |
.then(res => { | |
return res | |
}).then(output => { | |
console.log(output) | |
}) |
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
COMP10929:node-fetch-stuff $ http-echo-server | |
[server] event: listening (port: 3000) | |
[server] event: connection (socket#1) | |
[socket#1] event: resume | |
[socket#1] event: data | |
--> GET /hello HTTP/1.1 | |
--> Accept: */* | |
--> User-Agent: node-fetch/1.0 (+https://github.com/bitinn/node-fetch) | |
--> Accept-Encoding: gzip,deflate | |
--> Connection: close | |
--> x-datadog-trace-id: 2894019178293600090 | |
--> x-datadog-parent-id: 2894019178293600090 | |
--> x-datadog-sampled: 1 | |
--> x-datadog-sampling-priority: 1 | |
--> Host: localhost:3000 | |
--> | |
--> | |
[socket#1] event: prefinish | |
[socket#1] event: finish | |
[socket#1] event: readable | |
[socket#1] event: end | |
[socket#1] event: close |
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": "exampe_distributed_headers", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Eric Mustin", | |
"license": "ISC", | |
"dependencies": { | |
"dd-trace": "^0.17.1", | |
"http-echo-server": "^2.1.1", | |
"node-fetch": "^2.6.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment