AWS X射线跟踪在Node.js中的传出请求上中断 [英] aws x-ray tracing breaks on outgoing requests in Node.js
问题描述
嘿,我正在尝试跟踪Express应用程序的传出请求,但是我无法使它正常工作.
Hey I'm trying to trace outgoing requests from an express app, but I can't get it to work.
当我不使用AWSXRAY.captureHttpsGlobal函数时,一切都能很好地处理传入请求,并且我可以在服务映射"中看到我的应用程序,并且传入请求跟踪也将传入AWS,但是我想尽快跟踪传出请求我添加了AWSXRAY.captureHttpsGlobal,那么什么也没用,也没有任何异常,并且我的守护进程没有打印通常的成功发送一批1段(0.058秒)"
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)"
这是我的代码.
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!'))
推荐答案
可以共享您的代码在哪个节点运行时版本上运行以及您在使用哪个X-Ray SDK版本,以便我们可以尝试重现此问题. ?
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?
同时,我想分享一个自v1.2.0版本以来已解决的先前问题 https://github.com/aws/aws-xray-sdk-node/issues/18 如果不使用响应主体,则整个段将永远不会刷新到守护程序
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.
请让我知道.
这篇关于AWS X射线跟踪在Node.js中的传出请求上中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!