【发布时间】:2020-10-16 13:38:21
【问题描述】:
我想获取我的 Stepfunction 的特定执行的跟踪。
我 100% 为我的 stepfunction 启用 X-Ray 并授予它完全访问权限。
我使用 boto3 创建了一个 lambda,它描述了给定 executionArn 的执行。
问题是响应不完整!它没有给我traceHeader。 (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/stepfunctions.html)
我的 Lambda 代码:
import json
import boto3
import pprint
import botocore
def lambda_handler(event, context):
clientStepFunction = boto3.client('stepfunctions')
try:
response = clientStepFunction.describe_execution(executionArn="execArn...")
pprint.pprint(response)
except clientStepFunction.exceptions.ExecutionDoesNotExist:
print("Error Execution doesn't exists")
except clientStepFunction.exceptions.InvalidArn:
print("Error invalid arn")
return {
'statusCode': 200,
'body': json.dumps('Hello from Lamerarara!')
}
我很好地打印了回复:
{'ResponseMetadata': {...},
'executionArn': 'execArn',
'input': '{\n "IsHelloWorldExample": true\n}',
'name': 'execName',
'output': '[{\n'
' "IsHelloWorldExample": true\n'
'},{\n'
' "IsHelloWorldExample": true\n'
'}]',
'startDate': datetime.datetime(2020, 10, 16, 13, 21, 6, 724000, tzinfo=tzlocal()),
'stateMachineArn': 'stepMachineArn',
'status': 'SUCCEEDED',
'stopDate': datetime.datetime(2020, 10, 16, 13, 21, 10, 191000, tzinfo=tzlocal())}
谢谢!
解决方案:
终于是boto3的版本了。目前 aws 上的 boto3 版本不是最新的。你需要 boto3 1.15+ 来获取 traceHeader
【问题讨论】:
标签: amazon-web-services boto3 aws-step-functions aws-xray