如何停止“INIT_START事件后发生的“缺少AWS Lambda X-Ray跟踪数据”错误?

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

How do I stop "Missing AWS Lambda trace data for X-Ray" errors that happen after an INIT_START event?

问题

以下是您要翻译的内容:

The lambda's configs:

Logs and metrics (default): enabled
Active tracing: enabled
Enhanced monitoring: enabled

The role's permissions for xray:

"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries"

Whenever the lambda hits INIT_START:

INIT_START Runtime Version: nodejs:16.v13	Runtime Version
ARN: arn:aws:lambda:us-east-2::runtime:redacted

I get an error in the logs:

undefined	ERROR	Error: Missing AWS Lambda trace data for X-Ray.
Ensure Active Tracing is enabled and no subsegments are created outside the function handler.

Active tracing is enabled so I don't think that's the issue. There is no use of AWSXRay.getSegment. There are no other errors related to XRay in the logs, just the one after INIT_START.

What could be causing this? How do I track it down?

英文:

The lambda's configs:

Logs and metrics (default): enabled
Active tracing: enabled
Enhanced monitoring: enabled

The role's permissions for xray:

"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries"

Whenever the lambda hits INIT_START:

INIT_START Runtime Version: nodejs:16.v13	Runtime Version 
ARN: arn:aws:lambda:us-east-2::runtime:redacted

I get an error in the logs:

undefined	ERROR	Error: Missing AWS Lambda trace data for X-Ray. 
Ensure Active Tracing is enabled and no subsegments are created outside the function handler.

Active tracing is enabled so I don't think that's the issue. There is no use of AWSXRay.getSegment. There are no other errors related to XRay in the logs, just the one after INIT_START.

What could be causing this? How do I track it down?

答案1

得分: 0

确保活动跟踪已启用,并且没有在函数处理程序之外创建子段。Xray不支持在用户的Lambda函数之外创建子段。如果用户在Lambda函数之外调用API beginSubsegment(),每次Lambda初始化新的沙盒时都会出现此错误。

英文:

Ensure Active Tracing is enabled and no subsegments are created outside the function handler.

Xray does not support create subsegment outside of user's Lambda function. If user calls API beginSubsegment() NOT in Lambda function, every time Lambda initializes a new sandbox will get this error.

答案2

得分: 0

  1. 在与AWS支持团队解决此问题后,有两种可能的修复方法:

  2. 查找代码中所有进行跟踪的地方,并确认其是否正确实施 - 如果可能的话修复它。

  3. 在您的代码中设置一个名为 AWS_XRAY_CONTEXT_MISSING 的环境变量,其值为 IGNORE_ERROR

在我的情况下,第一种方法适用于我无法完全控制的代码库,并且我们对错误不太关心,因此我使用了环境变量来忽略lambda中的错误。

英文:

After sorting this out with AWS support there are two possible fixes:

  1. Find out all the places in your code where tracing is happening and confirm that it's being implemented properly -- fix if possible

  2. Set an env var AWS_XRAY_CONTEXT_MISSING with IGNORE_ERROR value in your code

In my case the first one was in a codebase that was a bit out of my control and we weren't very concerned about the error so I used the env var to just ignore the error in my lambda.

huangapple
  • 本文由 发表于 2023年5月26日 00:54:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76334631.html
匿名

发表评论

匿名网友

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

确定