如何在 Python 中使用 AWS Lambda 函数检测 X-Ray 中的其他函数?
How do I instrument additional functions in X-Ray with AWS Lambda function in Python?
我正在尝试使用 X Ray 检测 AWS Lambda 函数。根据 aws_xray_sdk
的 official documentation,我无法检测处理程序函数之外的任何内容。如果我有以下示例代码:
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("handler")
def my_handler(event, context):
# some code here
xray_recorder.begin_subsegment("my_function")
my_function(params)
xray_recorder.end_subsegment("my_function")
return {"message": "done"}
@xray_recorder.capture("my_function")
def my_function(params):
# do work
除了 handler
之外,X 射线跟踪中没有任何仪器。我尝试了 begin_subsegment
的不同组合,但 my_function
上没有 @xray_recorder.capture()
。 my_function
似乎没有生成任何痕迹。我该如何解决这个问题?
请尝试更改
xray_recorder.end_subsegment("my_function")
至
xray_recorder.end_subsegment()
我正在尝试使用 X Ray 检测 AWS Lambda 函数。根据 aws_xray_sdk
的 official documentation,我无法检测处理程序函数之外的任何内容。如果我有以下示例代码:
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("handler")
def my_handler(event, context):
# some code here
xray_recorder.begin_subsegment("my_function")
my_function(params)
xray_recorder.end_subsegment("my_function")
return {"message": "done"}
@xray_recorder.capture("my_function")
def my_function(params):
# do work
除了 handler
之外,X 射线跟踪中没有任何仪器。我尝试了 begin_subsegment
的不同组合,但 my_function
上没有 @xray_recorder.capture()
。 my_function
似乎没有生成任何痕迹。我该如何解决这个问题?
请尝试更改
xray_recorder.end_subsegment("my_function")
至
xray_recorder.end_subsegment()