-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
gh-132502: Prototyping adding timestamps to tracebacks. #129337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c5a9ccd
3dc00c2
a05766f
cdb67f0
99ffc8a
c119a02
bcc720b
b065394
09a547a
daa752d
e7fab86
e8a6297
6809426
0d83447
7c83ebf
beadfb8
354c5f0
33d20dd
2f72323
7f7357d
d9d2b1f
98b4593
c9ad56d
53b5500
8043b80
75072cb
eebec1d
9ff3234
f30c74d
85496cf
9c8eda4
6949cba
b564e63
e6199e3
4c031a6
23e2538
98ae94f
7d45424
dde0f39
5f7b930
964bdd3
5554b67
0f9bb1b
a55c3b1
d2d7583
84989bb
b268c82
d0f95ba
52a1e25
05d6f13
1fc9c88
4aaa4dc
ec22c19
1b83faf
1ba3ed4
1efbc2a
bab3575
77ffb5a
a0656ce
e4f54d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,36 @@ The following exceptions are used mostly as base classes for other exceptions. | |
|
||
.. versionadded:: 3.11 | ||
|
||
.. attribute:: __timestamp_ns__ | ||
|
||
The absolute time in nanoseconds at which this exception was instantiated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Time" according to what clock? Might as well be explicit |
||
(usually: when it was raised); the same accuracy as :func:`time.time_ns`. | ||
Display of these timestamps after the exception message in tracebacks is | ||
off by default but can be configured using the | ||
:envvar:`PYTHON_TRACEBACK_TIMESTAMPS` environment variable or the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs clarity about whether the variable controls timestamp collection or just presentation. |
||
:option:`-X traceback_timestamps <-X>` command line option. In | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want a knob in |
||
applications with complicated exception chains and exception groups it | ||
may be useful to help understand what happened when. The value will be | ||
``0`` if a timestamp was not recorded. :exc:`StopIteration` and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is being a control flow exception an exhaustive list of situations in which a timestamp may not be collected? The text suggests but doesn't state it. Also, I would expect timestamp collection to be super-cheap. Sure you don't want to just do it unconditionally? |
||
:exc:`StopAsyncIteration` never record timestamps as those are primarily | ||
for control flow. | ||
|
||
With ``PYTHON_TRACEBACK_TIMESTAMPS=iso`` in the environment :: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQ: why not a |
||
|
||
Traceback (most recent call last): | ||
File "<python-input-0>", line 1, in <module> | ||
raise RuntimeError("example") | ||
RuntimeError: example <@2025-02-08T01:21:28.675309Z> | ||
|
||
With ``PYTHON_TRACEBACK_TIMESTAMPS=ns`` in the environment :: | ||
|
||
Traceback (most recent call last): | ||
File "<python-input-0>", line 1, in <module> | ||
raise RuntimeError("example") | ||
RuntimeError: example <@1739172733527638530ns> | ||
|
||
.. versionadded:: next | ||
|
||
|
||
.. exception:: Exception | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.