Skip to content

Commit

Permalink
Add per-response-type duration
Browse files Browse the repository at this point in the history
It's sometimes useful to know response time separated out by status code.  Add another histogram for that.
  • Loading branch information
dannysauer committed May 27, 2021
1 parent cf55d2c commit 05a32fa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Curt Micol <asenchi@asenchi.com>
Dan Callaghan <dcallagh@redhat.com>
Dan Sully <daniel-github@electricrain.com>
Daniel Quinn <code@danielquinn.org>
Danny Sauer <danny.sauer@konghq.com>
Dariusz Suchojad <dsuch-github@m.zato.io>
David Black <github@dhb.is>
David Vincelli <david@freshbooks.com>
Expand Down
1 change: 1 addition & 0 deletions gunicorn/instrument/statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def access(self, resp, req, environ, request_time):
self.histogram("gunicorn.request.duration", duration_in_ms)
self.increment("gunicorn.requests", 1)
self.increment("gunicorn.request.status.%d" % status, 1)
self.histogram("gunicorn.request.status.%d.duration" % status, duration_in_ms)

# statsD methods
# you can use those directly if you want
Expand Down
1 change: 1 addition & 0 deletions tests/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_instrument():
assert logger.sock.msgs[0] == b"gunicorn.request.duration:7000.0|ms"
assert logger.sock.msgs[1] == b"gunicorn.requests:1|c|@1.0"
assert logger.sock.msgs[2] == b"gunicorn.request.status.200:1|c|@1.0"
assert logger.sock.msgs[3] == b"gunicorn.request.status.200.duration:7000.0|ms"


def test_prefix():
Expand Down

0 comments on commit 05a32fa

Please sign in to comment.