英文:
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
-
在与AWS支持团队解决此问题后,有两种可能的修复方法:
-
查找代码中所有进行跟踪的地方,并确认其是否正确实施 - 如果可能的话修复它。
-
在您的代码中设置一个名为
AWS_XRAY_CONTEXT_MISSING
的环境变量,其值为IGNORE_ERROR
。
在我的情况下,第一种方法适用于我无法完全控制的代码库,并且我们对错误不太关心,因此我使用了环境变量来忽略lambda中的错误。
英文:
After sorting this out with AWS support there are two possible fixes:
-
Find out all the places in your code where tracing is happening and confirm that it's being implemented properly -- fix if possible
-
Set an env var
AWS_XRAY_CONTEXT_MISSING
withIGNORE_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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论