GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python

Improve developer experience for uncaught exceptions on GCP

未關閉
#296 1 則留言 1 個 reaction 已指派 1 人 已被 @janell-chen 認領 在 GitHub 檢視
enhancement P2
主要語言
Python
星號
968
分支
128
PR 合併指標
30 天內沒有已合併 PR

描述

When a function executes and exits with an uncaught exceptions, the exception is logged as a regular plaintext Python traceback to stderr. The content is then captured into Cloud Logging as plaintext too, which makes it difficult to parse and analyze.

Consider the following dummy function:

```python
import functions_framework

@functions_framework.http
def test_crash(request):
raise ValueError("something doesn't work")
```

When calling this function, it (of course) crashes, and renders as follow:

![image](https://github.com/GoogleCloudPlatform/functions-framework-python/assets/65311/d995b32d-2773-437d-be74-2e2eff071a78)

This has several disadvantages:

* The error is spread over multiple line: it's not possible to point to a single log entry which contains the traceback, you always need to see here ~20 lines to get the full picture.
* The traceback only makes sense if Cloud Logging is sorted _from oldest to newest_ (I typically shows newest entries first, and the traceback is reversed :facepalm: )
* The error doesn't really show up in Error Reporting: only some of the exception, part of Flask, is caught into Error Reporting and it's really not useful:
![image](https://github.com/GoogleCloudPlatform/functions-framework-python/assets/65311/bfcf4070-e279-49c9-b26a-e204134cdd70)

Ideally, out of the box when running on GCP:

* The framework should log the error into a single `CRITICAL` log entry
* The error should be formatted to be reported automatically with the right content into Error Reporting

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。