首页 > 解决方案 > 如何使用 Python 中的 AWS Lambda 函数检测 X-Ray 中的其他函数?

问题描述

我正在尝试使用 X Ray 检测 AWS Lambda 函数。根据官方文档aws_xray_sdk我无法检测处理函数之外的任何内容。如果我有以下示例代码:

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

X 射线跟踪中除了handler. 我尝试过使用不同的组合begin_subsegment并且没有@xray_recorder.capture()on my_function。似乎没有任何迹象为my_function. 我该如何解决这个问题?

标签: pythonamazon-web-servicesaws-lambdaaws-xray

解决方案


请尝试改变

xray_recorder.end_subsegment("my_function")

xray_recorder.end_subsegment()

推荐阅读