简体   繁体   English

如何在AWS X-Ray管理控制台中打印自定义子分段?

[英]How to print custom subsegments in the AWS X-Ray management console?

I have added a main segment for routes for my REST API which is written in Node.js and runs on a Lambda function. 我为我的REST API添加了一个主要段,用Node.js编写并在Lambda函数上运行。 I have also enabled API gateway tracing for X-Ray. 我还为X-Ray启用了API网关跟踪。 I want to see sql query timing as a subsegment from X-Ray console so I have used AWSXRay.captureAsyncFunc function and added it for all sql queries and I am able to print tracing logs. 我想看看sql查询时间作为X-Ray控制台的一个子段,所以我使用了AWSXRay.captureAsyncFunc函数并为所有sql查询添加了它,我能够打印跟踪日志。 The following screenshot shows a segment and a subsegment for a GET request. 以下屏幕截图显示了GET请求的段和子段。

记录X射线段和子段

I want to see the subsegment in the AWS X-Ray management console. 我想在AWS X-Ray管理控制台中查看子分段。 In the tracing section of the X-Ray, I can only see API Gateway and Lambda timings. 在X射线的跟踪部分,我只能看到API网关和Lambda时序。

AWS X-Ray控制台中的API Gateway和Lambda段

Is anyone know how to print custom subsegments in the X-Ray timeline? 有人知道如何在X射线时间轴中打印自定义子分段吗?

When I click on raw data from X-Ray console, this is what I see. 当我从X-Ray控制台点击原始数据时,这就是我所看到的。 I want to be able to see my custom segment. 我希望能够看到我的自定义细分。 Raw data tab shows just segments of API Gateway and Lambda. 原始数据选项卡仅显示API网关和Lambda的各个部分。

原始数据选项卡

What is the Node runtime version of your Lambda function? Lambda函数的Node运行时版本是什么? Which type of lambda event handler are you using? 你使用哪种类型的lambda事件处理程序? Which version of X-Ray Node SDK are you using? 您使用的是哪个版本的X-Ray Node SDK? What style/library you are using for calling your SQL database? 您用于调用SQL数据库的样式/库是什么? Is it a callback, promise or async/await? 它是回调,承诺还是异步/等待?

The reason your getItem subsegment not shown is probably that in your tracing logs the subsegment doesn't have parent_id . 您的getItem段未显示的原因可能是您的跟踪日志中子段没有parent_id This is potentially an issue with the compatibility between Lambda node runtime and X-Ray SDK for Nodejs such that the SQL subsegment is not properly captured. 这可能是Lambda节点运行时和Nodejs的X-Ray SDK之间的兼容性问题,因此未正确捕获SQL子段。

Please feel free to open an issue on https://github.com/aws/aws-xray-sdk-node with the answers to the above questions provided so workaround/fixes can be addressed. 请随时在https://github.com/aws/aws-xray-sdk-node上打开一个问题,并提供上述问题的答案,以便解决变通方法/修复方法。

They are visible in the Raw Data tab in the console timeline view. 它们在控制台时间轴视图的“原始数据”选项卡中可见。 That shows the exact same json as returned by BatchGetTraces API. 这显示了与BatchGetTraces API返回的完全相同的json。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM