Skip to content

Collect timestamps on most exceptions for optional display on tracebacks. #132502

Description

@gpshead

Feature or enhancement

Proposal:

Why? to make debugging what happened in async servers with lots of exception groups and exceptions easier. Event timestamps reported on everything when emitting exception groups containing tracebacks often with their own nested causes would allow some semblance of order to be more readily understood and correlated with other parts of the distributed system.

Semi related to the rationale behind https://peps.python.org/pep-0785/ to make events in exception groups easier - when you've got an error report involving exception groups, potentially nested from async sources, reading that to understand what happened when is hard. But with timestamps on the exceptions rendered with the tracebacks you can better understand the ordering of events.

I've got a working implementation over in a PR 129337. It's time to file the tracking issue and polish things up for discussion.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. self-assigned this
    on Apr 14, 2025
  2. rocky-d commented on Mar 12, 2026

    @rocky-d

    While this gets considered for CPython core, there's already a PyPI package that does this today: dttb.

    One line to enable:

    import dttb
    dttb.apply()

    It patches both sys.excepthook and threading.excepthook to include timestamps on every traceback, supports timezone configuration and custom callbacks. Might be useful to folks who need this now, and could also serve as a reference for what the CPython implementation might look like.

  3. gpshead commented on Apr 14, 2026

    @gpshead
    MemberAuthor

    dttb and excepthook based things do not capture timestamps at the time of raise or handle timing of all exceptions within a chain or within ExceptionGroups.

  4. gpshead commented on Apr 14, 2026

    @gpshead
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions