一些保存的跟踪 ID 在 AWS X-Ray 控制台中找不到。

huangapple go评论103阅读模式
英文:

Some saved trace ids can not be found in aws xray console

问题

我正在使用aws_xray_sdk库来捕获追踪ID,然后将其保存在数据库中。

以下是有效的实现代码:

from aws_xray_sdk.core import lambda_launcher,

lambda_context = lambda_launcher.check_in_lambda()
trace_id = lambda_context.get_trace_entity().trace_id if lambda_context else None

除了这个实现之外,我没有与aws-xray-sdk相关的其他功能。

我能够成功地捕获追踪ID并将其存储在数据库中。然而,存在一个问题,即数据库中保存的一些追踪ID在AWS X-Ray控制台中找不到。

我期望使用aws_xray_sdk库的lambda_launcher方法捕获的追踪ID应该在AWS X-Ray控制台中可见。尽管我能够成功地捕获和保存这些追踪ID到数据库中,但我注意到数据库中存储的一些追踪ID无法在X-Ray控制台中找到。我想了解其他开发人员是否遇到过类似的情况,以及为什么会发生这种情况的任何见解。此外,我不确定是否需要显式配置xray_recorder以在AWS X-Ray控制台中正确显示追踪,因为我已经能够使用我已有的实现代码捕获追踪ID并将其存储在数据库中。

英文:

I am using the aws_xray_sdk library to capture trace IDs, which I then save in a database.

Here's the implementation that works well:

from aws_xray_sdk.core import lambda_launcher,

lambda_context = lambda_launcher.check_in_lambda()
trace_id = lambda_context.get_trace_entity().trace_id if lambda_context else None

I have no other functionality related to aws-xray-sdk, besides this implementation.

I'm able to successfully capture trace IDs and store them in the database. However, there's an issue where a few trace IDs saved in the database cannot be found in the AWS X-Ray console.

I expect that the trace IDs I capture using the aws_xray_sdk library's lambda_launcher method should be visible in the AWS X-Ray console. Although I can successfully capture and save these trace IDs in a database, I've noticed that a few trace IDs stored in the database cannot be located in the X-Ray console. I'm interested in learning if other developers have faced a similar situation and if there's any insight into why this might be happening. Additionally, I'm uncertain whether I need to configure the xray_recorder explicitly for proper trace visibility in the AWS X-Ray console, as I'm already able to capture trace IDs and store them in the database with the implementation I already have.

答案1

得分: 0

你是否将X-Ray SDK的采样规则设置为100%?因为默认情况下,X-Ray SDK会对每秒的第一个请求进行采样,并对其他请求进行5%的采样。有可能你捕获的一些追踪信息没有被采样,也就是说它们没有被发送到X-Ray服务。

在这里了解更多关于采样规则的信息:
https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html

英文:

Have you set the sampling rules of X-Ray SDK to 100%? Because by default, X-Ray SDK samples the first request of each second and five percent of any additional requests. It is possible that some of the traces you captured are not sampled, meaning they do not get sent to the X-Ray Service.

Read more about sampling rules here:
https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html

答案2

得分: 0

我没有找到解决方案。但是,我找到了一种通过在Cloudwatch控制台的日志洞察面板中进行过滤来查找trace-id的方法。


  1. 导航到CloudWatch控制台。
  2. 在左侧的日志下方,点击"Logs Insights"。
  3. 选择日志组。
  4. 指定应该捕获trace ID的开始和结束日期。
  5. 输入一个查询,专门用于过滤trace ID,如下所示:
    fields @timestamp, @message, @logStream, @log| filter @message like "<trace-id>"| sort @timestamp asc
    

    请注意,此查询旨在根据您正在搜索的trace ID过滤日志。

英文:

I did not find a solution for this. But, I did however find a way to still find the trace-id by filtering through the logs insights panel in the Cloudwatch console.


  1. Navigate to the CloudWatch console.
  2. Click on "Logs Insights" located on the left side below Logs.
  3. Choose the log group.
  4. Specify the start and end dates for when the trace ID should have been captured.
  5. Enter a query to filter specifically for the trace ID, as demonstrated below:
    fields @timestamp, @message, @logStream, @log| filter @message like &quot;&lt;trace-id&gt;&quot;| sort @timestamp asc
    

    Please note that this query is meant to filter the logs based on the trace ID you are searching for.

huangapple
  • 本文由 发表于 2023年8月8日 19:38:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76859195.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定