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

Xray not capturing stack traces in latest version of Flask

未关闭
#269 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@srprash 已经在做这个了。

开始于 2021年1月26日。

评估

这个 Issue 还没有评估数据。

描述

bug pending release

The after_request handler is closing the segment before the teardown_request handler is called so the stack trace isn't captured.

It looks like this behavior changed as of Flask v1.1.0 (specifically https://github.com/pallets/flask/pull/3266)

Currently using:

  • aws-xray-sdk v2.6.0
  • flask v1.1.2

Here is our current work around:

app = Flask(__name__)

def wrap_exception_handler(handler):
    def wrapped_function(exp):
        if not isinstance(exp, HTTPException) or exp.code >= 500:
            try:
                stack = stacktrace.get_stacktrace(
                    limit=xray_recorder.max_trace_back,
                )

                xray_recorder.current_segment().add_exception(exp, stack)
            except Exception:
                app.logger.error('Failed to add stack trace to xray segment')

        return handler(exp)
    return wrapped_function

app.handle_user_exception = wrap_exception_handler(app.handle_user_exception)
主要语言
Python
星标
340
派生
148
平均合并
7 天 8 小时
30 天内合并 PR
2

环境准备

从这里开始

  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 摘要。