gpt4 book ai didi

java - 带有 Java SQS JMS 连接器的 AWS Xray

转载 作者:搜寻专家 更新时间:2023-10-31 20:17:22 25 4
gpt4 key购买 nike

我们最近开始将 AWS Xray 添加到我们的 Spring 项目中,并成功利用 AWSXRayServletFilter 创建 Segments 来满足我们的客户请求。

现在我们还开始添加 AWS SDK Instrumentor 来跟踪我们对 AWS 服务的使用情况。其中之一是 SQS,我们使用 amazon-sqs-java-messaging-lib 来利用 JMS 接收 SQS 消息。这是我们面临一些麻烦的地方。

每次我们的应用程序尝试获取消息时,TracingHandler 都会尝试创建一个SubSegment,但会失败,因为尚未创建Segment。我们如何将这些请求包装在 Segment 中?该信息不会包含在消息本身中以将来自将消息推送到队列的资源的段链接在一起吗?

我本来希望有 Context Missing 策略可用于创建一个段,如果一个丢失或至少从父跟踪 ID 中获取,但我没有看到他们最新的 docs 中包含该信息.

最佳答案

这是一个已知问题,已经在官方论坛上讨论过了。这里有几个链接: https://forums.aws.amazon.com/thread.jspa?threadID=252012&tstart=0 https://forums.aws.amazon.com/thread.jspa?threadID=257258&tstart=25

Every time our application attempts to get messages the TracingHandler attempts to create a SubSegment and fails because there is no Segment already created. How can we wrap these requests in a Segment? Wouldn't that information be contained in the message itself to link segments together from the resource that pushed the message to the queue?

Segment 信息保存在 ThreadLocal 中。如果您在单独的线程中运行某些内容,则必须手动创建一个段,因此在创建子段时您将拥有所需的 ThreadLocal 数据。 SQS 消息甚至与 X-Ray 服务相关的 SQS 服务本身都没有什么特别之处。它仅使用 SQS 客户端,使 X-Ray 通过使用处理程序跟踪 ThreadLocal 数据来推断对 SQS 的调用已经发生。

I would have expected there to Context Missing strategy available to create a Segment if one is missing or at least pick up from a parent trace id but I don't see that information contained within their latest docs.

那是我的功能请求之一。查看线程及其官方答案以及我在尝试自己实现此类上下文缺失策略时发现的当前限制。 https://forums.aws.amazon.com/thread.jspa?threadID=252012&tstart=0

关于java - 带有 Java SQS JMS 连接器的 AWS Xray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45826489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com