Warning 'No subsegment to end' written to logs when X-Ray SDK is disabled.
@srprash 已经在做这个了。
开始于 2022年4月18日。
评估
这个 Issue 还没有评估数据。
描述
When running locally, I don't want X-Ray to be enabled. Out of the box, the sam local start-lambda logs warnings about the X-Ray SDK, but I'm trying to disable the SDK entirely.
I'm disabling the SDK by checking the environment variable AWS_SAM_LOCAL. If it's present and it's value is 'true', then the global SDK config is disabled. Then when I patch the desired libraries, nothing happens and there are no [INFO] logs. That's good.
from aws_xray_sdk import global_sdk_config as global_xray_sdk_config
from aws_xray_sdk.core import patch, xray_recorder
if environ.get('AWS_SAM_LOCAL', 'false') == 'true':
global_xray_sdk_config.set_sdk_enabled(False)
patch(['boto3', 'requests'])
However, I have a function that adds a subsegment, and this is emitting logs even with the X-Ray SDK disabled.
def add_xray_subsegment(name: str, annotations: dict, e: Exception = None) -> None:
with xray_recorder.capture(name) as subsegment:
a = {k: v for k, v in annotations.items() if v is not None}
for k, v in a.items():
subsegment.put_annotation(k, v)
if e:
limit = xray_recorder._max_trace_back
stack = traceback.extract_stack(limit=limit)
subsegment.add_exception(e, stack)
[WARNING] {date} {request-id} No subsegment to end.
While the function still works locally, it's causing delay because people don't expect to see these warnings in the logs and are wasting their time investigating.
I'm guessing this isn't expected behaviour with the SDK disabled; so is this a bug, or is there some other configuration that I can add to remove the warnings?
Thanks.
- 主要语言
- Python
- 星标
- 339
- 派生
- 147
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/aws-xray-sdk-python 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 68/100
aws/aws-xray-sdk-python#490 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 1/100
aws/aws-xray-sdk-python#460 ·
-
Next release 未关闭
难度 5/5 一周以上 新手友好度 20/100
aws/aws-xray-sdk-python#457 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
aws/aws-xray-sdk-python#453 ·
-
难度 4/5 3-5 天 新手友好度 35/100
aws/aws-xray-sdk-python#452 · 1 个 reaction ·
查看 aws/aws-xray-sdk-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
stephrobert/dsoxlab#238 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
sublimehq/package_control#1780 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 70/100
nwg-piotr/nwg-displays#145 ·