Skip to content

Improve developer experience for uncaught exceptions on GCP #296

@multani

Description

@multani

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:

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

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 🤦 )
  • 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

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions