Merge ~twom/launchpad:stats-5xx-errors into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 4bdf5eb464207614c95f9989584998009e2926bb
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:stats-5xx-errors
Merge into: launchpad:master
Prerequisite: ~twom/launchpad:stats-queues-in-buildd
Diff against target: 42 lines (+6/-0)
1 file modified
lib/lp/services/webapp/publication.py (+6/-0)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+390143@code.launchpad.net

This proposal supersedes a proposal from 2020-09-02.

Commit message

Add statsd output for 400 and 5XX errors

Description of the change

We already gather these stats into the OpStats and then into LPStats.
Add statsd output for the same things in the same places.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve
~twom/launchpad:stats-5xx-errors updated
4bdf5eb... by Tom Wardill

Fix for new client retrieval method

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
2index d0ad83e..a289f44 100644
3--- a/lib/lp/services/webapp/publication.py
4+++ b/lib/lp/services/webapp/publication.py
5@@ -73,6 +73,7 @@ from lp.services.database.policy import LaunchpadDatabasePolicy
6 from lp.services.features.flags import NullFeatureController
7 from lp.services.oauth.interfaces import IOAuthSignedRequest
8 from lp.services.osutils import open_for_writing
9+from lp.services.statsd.interfaces.statsd_client import IStatsdClient
10 import lp.services.webapp.adapter as da
11 from lp.services.webapp.interfaces import (
12 FinishReadOnlyRequestEvent,
13@@ -727,6 +728,7 @@ class LaunchpadBrowserPublication(
14 da.clear_request_started()
15
16 getUtility(IOpenLaunchBag).clear()
17+ statsd_client = getUtility(IStatsdClient)
18
19 # Maintain operational statistics.
20 if getattr(request, '_wants_retry', False):
21@@ -744,10 +746,13 @@ class LaunchpadBrowserPublication(
22 status = request.response.getStatus()
23 if status == 404: # Not Found
24 OpStats.stats['404s'] += 1
25+ statsd_client.incr('errors.404')
26 elif status == 500: # Unhandled exceptions
27 OpStats.stats['500s'] += 1
28+ statsd_client.incr('errors.500')
29 elif status == 503: # Timeouts
30 OpStats.stats['503s'] += 1
31+ statsd_client.incr('errors.503')
32
33 # Increment counters for status code groups.
34 status_group = str(status)[0] + 'XXs'
35@@ -756,6 +761,7 @@ class LaunchpadBrowserPublication(
36 # Increment counter for 5XXs_b.
37 if is_browser(request) and status_group == '5XXs':
38 OpStats.stats['5XXs_b'] += 1
39+ statsd_client.incr('errors.5XX')
40
41 # Make sure our databases are in a sane state for the next request.
42 thread_name = threading.current_thread().name

Subscribers

People subscribed via source and target branches

to status/vote changes: