aws x-ray tracing breaks on outgoing requests in Node.js

那年仲夏 提交于 2019-12-10 23:08:03

问题


Hey I'm trying to trace outgoing requests from an express app, but I can't get it to work.

When I dont use the AWSXRAY.captureHttpsGlobal function everything works fine with incoming requests and I can see my application in "Service Map" and my incoming request traces coming in on AWS, but I want to trace outgoing requests and as soon as I add AWSXRAY.captureHttpsGlobal then nothing works and I get no exception or anything, and my Daemon doesnt print the usual "Successfully sent batch of 1 segments (0.058 seconds)"

This is my code.

var AWSXRay = require('aws-xray-sdk');
const express = require("express");

var app = express();
app.use(AWSXRay.express.openSegment('MyApp'));

AWSXRay.captureHTTPsGlobal(require('https')); // works when i comment this out
var http = require('https');


app.get('/', function (req, res) {
    http.get("https://google.com", (resp) => {
        res.send("googlefetched")
    });
    //res.send("hello world")

});

app.use(AWSXRay.express.closeSegment());
app.listen(3000, () => console.log('Example app listening on port 3000!'))

回答1:


could you share which node runtime version your code is running at and which X-Ray SDK version you are using so we can try to reproduce this issue on our side?

At the meantime I would like to share a previous issue that has been fixed since v1.2.0 https://github.com/aws/aws-xray-sdk-node/issues/18 where if the response body is not consumed then the entire segment will never be flushed to the daemon.

Please let me know.



来源:https://stackoverflow.com/questions/50279527/aws-x-ray-tracing-breaks-on-outgoing-requests-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!