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

logging.exception does not create entry in exceptions table

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

还没有人认领这个 Issue。

评估

这个 Issue 还没有评估数据。

描述

area:python-functions needs-investigation

When logging.exception("Simple Exception") then it should show up in the exceptions table in App Insights. It only shows up when it is explicitly raised.

If we want to show 403,404 as an "exception from the app's point of view" and correlate with requests etc currently the app insights will only show failures that explicitly raised an exception. If a valid HttpResponse is sent with 403, it will be shown as successful request because the function executed successfully. But from the app's point of view, if it needs a simple correlation between requests/traces and exceptions, the workaround is to use logging.exception and assign it a error for ease of querying.

But the logging.exception when used outside of a try/catch context in Python functions does not log the exception inside exceptions table in app insights.

Here is a sample code that can be used to test this:

def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: logging.exception("Before exception logging") try: raise ValueError("Oops. something went wrong") except ValueError as err: logger.exception("Simple exception logging:" + str(err)) #raise #HTTP 500 kill -> failed.

In this sample "Before exception logging" statement does not show up in the exceptions table
traces
| where message contains "Before"

exceptions
| where message contains "Before"

Overall this would have been an easier stopgap method to correlate exceptions in Python as it does not have a provision to override the custom telemetry model offered by App Insights.

主要语言
Python
星标
357
派生
117
平均合并
9 天 27 分钟
30 天内合并 PR
3

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

Azure/azure-functions-python-worker 的其他 Issue

查看 Azure/azure-functions-python-worker 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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