AWS X-Ray Python:MissingEndTime 错误
AWS X-Ray Python: MissingEndTime error
我想使用 X-Ray SDK 跟踪对 Python AWS SDK (boto3
) 的调用。根据 X-Ray docs,我必须修补 boto3
。然后 X-Ray 会自动创建子分段,因此我只需将 AWS SDK 调用包围在一个分段内。这是我的代码:
import boto3
from aws_xray_sdk.core import xray_recorder, patch_all
patch_all()
codecommit = boto3.client("codecommit")
# begin a segment
xray_recorder.begin_segment("Main")
# create a CodeCommit repository named "myrepo1"
codecommit.create_repository(repositoryName="myrepo1")
# end a segment
xray_recorder.end_segment("Main")
首先我 start the X-Ray daemon,然后我 运行 脚本。但是,守护进程returns出现以下错误:
2018-07-27T15:33:01+08:00 [Info] Successfully sent batch of 1 segments (0.146 seconds)
2018-07-27T15:33:01+08:00 [Error] Unprocessed segment: {
ErrorCode: "MissingEndTime",
Id: "74d23cdcc7b60c3f",
Message: "Invalid segment. ErrorCode: MissingEndTime"
}
2018-07-27T15:33:01+08:00 [Warn] Batch that contains unprocessed segments
2018-07-27T15:33:01+08:00 [Warn] {"aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "1.1.2"}}, "end_time": "MainSegment", "id": "74d23cdcc7b60c3f", "in_progress": false, "name": "MainSegment", "service": {"runtime": "CPython", "runtime_version": "3.6.5"}, "start_time": 1532676780.5897238, "subsegments": [{"aws": {"operation": "CreateRepository", "region": "ap-southeast-1", "request_id": "4a82bf29-916f-11e8-a631-85af1e9bc33f"}, "end_time": 1532676781.4089937, "http": {"response": {"status": 200}}, "id": "8ec94650265cf358", "in_progress": false, "name": "codecommit", "namespace": "aws", "parent_id": "74d23cdcc7b60c3f", "start_time": 1532676780.617356, "subsegments": [{"end_time": 1532676781.0933495, "http": {"request": {"method": "POST", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}}, "id": "77c7d8a0f67f8e13", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.0926085, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.40752, "http": {"request": {"method": "POST", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "530f510699b9a050", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.093692, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.4083207, "http": {"request": {"method": "READ", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "ad9b717abe0773e5", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.408112, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.408436, "http": {"request": {"method": "READ", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "9d0e8e7b08a3030b", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.4084244, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}], "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}], "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3"}
此外,当我在 AWS 控制台上查看 X-Ray 时,服务图表或痕迹上没有任何显示。
在网上搜索时,我找不到任何此错误的实例。我错过了什么吗?
我在 AWS 论坛上询问并得到了 answer。
如果一个参数被传递给xray_recorder.end_segment()
,它会在几秒钟内被自动解析为纪元。可以留空。
我想使用 X-Ray SDK 跟踪对 Python AWS SDK (boto3
) 的调用。根据 X-Ray docs,我必须修补 boto3
。然后 X-Ray 会自动创建子分段,因此我只需将 AWS SDK 调用包围在一个分段内。这是我的代码:
import boto3
from aws_xray_sdk.core import xray_recorder, patch_all
patch_all()
codecommit = boto3.client("codecommit")
# begin a segment
xray_recorder.begin_segment("Main")
# create a CodeCommit repository named "myrepo1"
codecommit.create_repository(repositoryName="myrepo1")
# end a segment
xray_recorder.end_segment("Main")
首先我 start the X-Ray daemon,然后我 运行 脚本。但是,守护进程returns出现以下错误:
2018-07-27T15:33:01+08:00 [Info] Successfully sent batch of 1 segments (0.146 seconds)
2018-07-27T15:33:01+08:00 [Error] Unprocessed segment: {
ErrorCode: "MissingEndTime",
Id: "74d23cdcc7b60c3f",
Message: "Invalid segment. ErrorCode: MissingEndTime"
}
2018-07-27T15:33:01+08:00 [Warn] Batch that contains unprocessed segments
2018-07-27T15:33:01+08:00 [Warn] {"aws": {"xray": {"sdk": "X-Ray for Python", "sdk_version": "1.1.2"}}, "end_time": "MainSegment", "id": "74d23cdcc7b60c3f", "in_progress": false, "name": "MainSegment", "service": {"runtime": "CPython", "runtime_version": "3.6.5"}, "start_time": 1532676780.5897238, "subsegments": [{"aws": {"operation": "CreateRepository", "region": "ap-southeast-1", "request_id": "4a82bf29-916f-11e8-a631-85af1e9bc33f"}, "end_time": 1532676781.4089937, "http": {"response": {"status": 200}}, "id": "8ec94650265cf358", "in_progress": false, "name": "codecommit", "namespace": "aws", "parent_id": "74d23cdcc7b60c3f", "start_time": 1532676780.617356, "subsegments": [{"end_time": 1532676781.0933495, "http": {"request": {"method": "POST", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}}, "id": "77c7d8a0f67f8e13", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.0926085, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.40752, "http": {"request": {"method": "POST", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "530f510699b9a050", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.093692, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.4083207, "http": {"request": {"method": "READ", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "ad9b717abe0773e5", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.408112, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}, {"end_time": 1532676781.408436, "http": {"request": {"method": "READ", "url": "https://codecommit.ap-southeast-1.amazonaws.com/"}, "response": {"status": 200}}, "id": "9d0e8e7b08a3030b", "in_progress": false, "name": "https://codecommit.ap-southeast-1.amazonaws.com/", "namespace": "remote", "parent_id": "8ec94650265cf358", "start_time": 1532676781.4084244, "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}], "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3", "type": "subsegment"}], "trace_id": "1-5b5acaac-b87df6ecbf3edbb29d4442f3"}
此外,当我在 AWS 控制台上查看 X-Ray 时,服务图表或痕迹上没有任何显示。
在网上搜索时,我找不到任何此错误的实例。我错过了什么吗?
我在 AWS 论坛上询问并得到了 answer。
如果一个参数被传递给xray_recorder.end_segment()
,它会在几秒钟内被自动解析为纪元。可以留空。