【问题标题】:AWS Xray: Cannot create segments inside Lambda function and segment not foundAWS Xray:无法在 Lambda 函数中创建分段并且未找到分段
【发布时间】:2018-08-24 10:08:34
【问题描述】:

我遇到了一个非常奇怪的行为,我正在关注在线文档,并在创建一个片段来处理我的子片段时,lambda 按以下顺序执行:

xray_recorder.begin_segment('segment-name')
xray_recorder.begin_subsegment('subsegment-name')
# put annotations and meta data etc
xray_recorder.end_segment('segment-name')
xray_recorder.end_subsegment('subsegment-name')

但我在 CloudWatch Manager 上收到以下错误:

Cannot create segments inside Lambda function. Discarded.

当我删除段创建并尝试像这样在本地运行时:

xray_recorder.begin_subsegment('subsegment-name')
# put annotations and meta data etc
xray_recorder.end_segment('segment-name')

我收到错误:SegmentNotFoundException:找不到当前段/子段,请确保您有一个段打开

令人困惑。

【问题讨论】:

    标签: python aws-lambda aws-xray


    【解决方案1】:

    虽然在本地运行 xray 分段是在本地创建的,并且您必须启动分段以创建子分段,但是在 AWS 上的 lambda 上运行时,分段是默认创建的,您可以继续处理子分段。

    在本地我遇到了错误,而忽略了段的创建,而它在远程工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多