feature: record duration using monotonic time - #3399
Open
sfozz wants to merge 2 commits into
Open
Conversation
pajod
reviewed
May 17, 2025
pajod
reviewed
May 17, 2025
sfozz
force-pushed
the
nano_duration_access_log
branch
7 times, most recently
from
June 27, 2025 03:20
c94a100 to
9a59cee
Compare
Author
|
I've cleaned this up and made the change more intentional.
|
So that if you have other systems that record durations to this resolution then they can be in alignment without needing calculation.
sfozz
force-pushed
the
nano_duration_access_log
branch
from
June 23, 2026 10:38
9a59cee to
691f71d
Compare
Author
|
Oh I see what you mean now... I've just tested extending the I've updated the PR description to more acuuratly cover the purpose of the change. |
sfozz
force-pushed
the
nano_duration_access_log
branch
from
June 23, 2026 21:20
eadeb5c to
1ea2f3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds nanosecond-resolution request timing to the access log and switches the underlying measurement to a monotonic
clock.
What's new
%(N)saccess-log atom for request time in nanoseconds. This lets gunicorn line up directly with other systems(tracing, metrics pipelines, various proxies) that already record duration at nanosecond resolution, so they agree
without any unit conversion.
time.monotonic_ns()instead ofdatetime.now(). Using the monotonic timer means that duration is recorded precisely and without the possibility of inaccurate records due to the system clock changing.Details
with plain integer arithmetic:
T: secondsM: millisecondsD: microsecondsN: nanoseconds (new)L: decimal seconds (to microsecond precision)Natom.Implements #3398