Skip to content

Instantly share code, notes, and snippets.

@snawaz
Created March 16, 2019 05:55
Show Gist options
  • Save snawaz/0fc8ff3f5e964f146d8abf9cf344aea6 to your computer and use it in GitHub Desktop.
Save snawaz/0fc8ff3f5e964f146d8abf9cf344aea6 to your computer and use it in GitHub Desktop.
Jaeger headers forwarding with Isito does not work
'use strict';
const express = require('express');
// Constants
const PORT = 8080;
const HOST = '0.0.0.0';
// App
const app = express();
app.get('/', (req, res) => {
var s = "headers: ";
var h = req.headers;
for(var key in h) {
s += key + ": " + h[key] + "\n";
}
res.send('app_one.v2: Hello world\n\n' + s);
});
app.listen(PORT, HOST);
console.log(`Running app_one on http://${HOST}:${PORT}`);
'use strict';
const express = require('express');
const request = require('request');
// Constants
const PORT = 8081;
const HOST = '0.0.0.0';
// App
const app = express();
function as_string(o) {
return JSON.stringify(o, null, ' ');
}
app.get('/2/echo', (req, res) => {,
var opts = {
"url": "http://app-one-svc:8080/",
"headers" : {
"x-b3-traceid": req.headers["x-b3-traceid"],
"x-b3-spanid" : req.headers["x-b3-spanid"],
"x-b3-sampled": req.headers["x-b3-sampled"],
"x-request-id": req.headers["x-request-id"]
}
};
request(opts, function(err, rs, body) {
var s = as_string(req.headers)
+ "\nBACKEND:\n"
+ "\n\tERR: " + err
+ "\n\tRES: " + as_string(rs)
+ "\n\tBDY: " + body
+ "\n\topts: " + as_string(opts);
res.send('app_two.v2: Echoing from backend...\n\n' + s);
});
});
app.listen(PORT, HOST);
console.log(`Running app_two on http://${HOST}:${PORT}`);
app_two.v2: Echoing from backend...
{
"host": "192.168.99.106:31380",
"user-agent": "curl/7.54.0",
"accept": "*/*",
"x-forwarded-for": "172.17.0.1",
"x-forwarded-proto": "http",
"x-envoy-internal": "true",
"x-request-id": "4833e88b-ec7a-928a-931a-0c4a2ff96c9e",
"x-envoy-decorator-operation": "app-two-svc.default.svc.cluster.local:8081/2/echo",
"x-b3-traceid": "25ec6c82faefc749",
"x-b3-spanid": "25ec6c82faefc749",
"x-b3-sampled": "1",
"x-istio-attributes": "Ck8KCnNvdXJjZS51aWQSQRI/a3ViZXJuZXRlczovL2lzdGlvLWluZ3Jlc3NnYXRld2F5LTdmZjhkOGI1NTctNThibGQuaXN0aW8tc3lzdGVtCj4KE2Rlc3RpbmF0aW9uLnNlcnZpY2USJxIlYXBwLXR3by1zdmMuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbApBChdkZXN0aW5hdGlvbi5zZXJ2aWNlLnVpZBImEiRpc3RpbzovL2RlZmF1bHQvc2VydmljZXMvYXBwLXR3by1zdmMKQwoYZGVzdGluYXRpb24uc2VydmljZS5ob3N0EicSJWFwcC10d28tc3ZjLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwKKgodZGVzdGluYXRpb24uc2VydmljZS5uYW1lc3BhY2USCRIHZGVmYXVsdAopChhkZXN0aW5hdGlvbi5zZXJ2aWNlLm5hbWUSDRILYXBwLXR3by1zdmM=",
"content-length": "0"
}
BACKEND:
ERR: null
RES: {
"statusCode": 200,
"body": "app_one.v2: Hello world\n\nheaders: x-b3-traceid: 25ec6c82faefc749\nx-b3-spanid: 25ec6c82faefc749\nx-b3-sampled: 1\nx-request-id: 4833e88b-ec7a-928a-931a-0c4a2ff96c9e\nhost: app-one-svc:8080\nconnection: close\n",
"headers": {
"x-powered-by": "Express",
"content-type": "text/html; charset=utf-8",
"content-length": "203",
"etag": "W/\"cb-F/Kyvo0Pde3nbBfUVn3w/8lmTR0\"",
"date": "Sat, 16 Mar 2019 05:54:54 GMT",
"connection": "close"
},
"request": {
"uri": {
"protocol": "http:",
"slashes": true,
"auth": null,
"host": "app-one-svc:8080",
"port": "8080",
"hostname": "app-one-svc",
"hash": null,
"search": null,
"query": null,
"pathname": "/",
"path": "/",
"href": "http://app-one-svc:8080/"
},
"method": "GET",
"headers": {
"x-b3-traceid": "25ec6c82faefc749",
"x-b3-spanid": "25ec6c82faefc749",
"x-b3-sampled": "1",
"x-request-id": "4833e88b-ec7a-928a-931a-0c4a2ff96c9e"
}
}
}
BDY: app_one.v2: Hello world
headers: x-b3-traceid: 25ec6c82faefc749
x-b3-spanid: 25ec6c82faefc749
x-b3-sampled: 1
x-request-id: 4833e88b-ec7a-928a-931a-0c4a2ff96c9e
host: app-one-svc:8080
connection: close
opts: {
"url": "http://app-one-svc:8080/",
"headers": {
"x-b3-traceid": "25ec6c82faefc749",
"x-b3-spanid": "25ec6c82faefc749",
"x-b3-sampled": "1",
"x-request-id": "4833e88b-ec7a-928a-931a-0c4a2ff96c9e"
}
}
@snawaz
Copy link
Author

snawaz commented Mar 16, 2019

I'm calling app-two-svc: curl http://192.168.99.106:31380/2/echo .. which calls app-one-svc.

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