Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Issue with passing trace_entity when using ThreadPoolExecutor in lambda

未关闭
#342 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
aws, python

调研方向

从 README 的 ThreadPoolExecutor 示例开始,检查用于 lambda 的自定义上下文类,尤其是 trace entity 的初始化和设置方式。重现线程处理的第一个 job,并验证其 subsegment 会附加到所提供的 trace entity,而无需预先调用 get_trace_entity。

由索引模型根据 Issue 内容生成。

描述

I followed the instructions in the readme for passing the trace entity in a ThreadPoolExecutor but this does not appear to work properly in a lambda. The first time a thread does some work the trace_entity does not stick and the subsegment gets put under the root node not the one it should be assiciated with. The next time a thread picks up a job everything seems to operate fine.

I dug into the code a bit and it seems like there is a custome context class for lambdas but it does not override set_trace_entity to work properly with the other changes in the class. To workaround the issue I have found calling get_trace_entity before setting sets the internal state up properly.

example workaround from readme

def load_url(url, trace_entity):
    xray_recorder.get_trace_entity() # Workaround to setup internal state
    xray_recorder.set_trace_entity(trace_entity)

    resp = requests.get(url)

    xray_recorder.clear_trace_entities()
    return resp
主要语言
Python
星标
340
派生
148
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws/aws-xray-sdk-python 的其他 Issue

查看 aws/aws-xray-sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。