Skip to content

Report exceptions from logger.exception() #134

@unflxw

Description

@unflxw

Investigate whether we should and can do this.

Python logger context

Python's built-in logging package allows for log messages to include exception information.

If the logging method is called from an exception handler (an except block) with the exc_info=True parameter, then it will report information about the currently handled exception. (A specific exception instance can also be passed as the value for exc_info)

There is also a logger.exception() method, which already sets exc_info=True, and which is meant to be used from within exception handlers.

Possible implementations

We could implement a logging handler which, if an exception is present, reports it to AppSignal (doing the equivalent of send_error() for it)

Would this be useful? Perhaps this would also report exceptions that are not relevant to the user. Users might prefer to have finer control over it by calling appsignal.send_error() manually.

We could patch the logging module (OpenTelemetry contrib does it, to implement some other functionality) to add this to all loggers, or we could provide a handler that allows users to add it to their logger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn improvement to an existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions