Created
April 29, 2020 11:41
-
-
Save ericmustin/041a127b5bdea282ad0d4e8d3f4fc8c8 to your computer and use it in GitHub Desktop.
example_http_request
This file contains 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 | |
// different terminal window from run `http-echo-server` | |
// node index.js | |
const tracer = require('dd-trace').init({debug: false}) | |
const axios = require('axios') | |
const express = require('express') | |
async function init(req, res) { | |
var axresponse = await axios.post('http://localhost:3000?ok=ok', { | |
firstName: 'Fred', | |
lastName: 'Flintstone' | |
}) | |
console.log('response', axresponse.status) | |
res.status(200).send('Hello World!') | |
} | |
const app = express() | |
const port = 5000 | |
app.get('/', init) | |
app.listen(port, () => console.log(`Example app listening on port ${port}!`)) | |
// Text Extraction, set debug to true to see extracted context: | |
// curl -H "X-Datadog-Trace-Id: 3238677264721744442" -H "x-datadog-parent-id: 0" -H "x-datadog-sampling-priority: 1" -H "x-datadog-origin: synthetics" localhost:5000 |
This file contains 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_http_request", | |
"version": "1.0.0", | |
"description": "", | |
"main": "example_http_request.js", | |
"scripts": { | |
"start": "node example_http_request.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"axios": "^0.19.1", | |
"express": "^4.17.1", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment