Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: add metric for all mobile bridge "unregistered" user drops
Browse files Browse the repository at this point in the history
* normalized metric name and tags

Closes #1421
  • Loading branch information
jrconlin committed Jul 28, 2020
1 parent 480f5ba commit 37516a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion autopush/router/adm.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _route(self, notification, uaid_data):
self.metrics.increment("notification.bridge.error",
tags=make_tags(
self._base_tags,
reason="connection_unavailable"))
reason="connection unavailable"))
raise RouterException("Server error", status_code=502,
errno=902,
log_exception=False)
Expand Down
9 changes: 1 addition & 8 deletions autopush/router/apnsrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,14 @@ def _route(self, notification, router_data):
else:
reason = "unknown"
if isinstance(e, RouterException) and e.status_code in [404, 410]:
self.metrics.increment(
"notification.bridge.connection.error",
tags=make_tags(
self._base_tags,
application=rel_channel,
reason="unregistered"
))
raise RouterException(
str(e),
status_code=e.status_code,
errno=106,
response_body="User is no longer registered",
log_exception=False
)
self.metrics.increment("notification.bridge.connection.error",
self.metrics.increment("notification.bridge.error",
tags=make_tags(self._base_tags,
application=rel_channel,
reason=reason))
Expand Down
6 changes: 3 additions & 3 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_bad_send(self):
'User is no longer registered')

@inlineCallbacks
def test_aaaa_fail_send(self):
def test_fail_send(self):
def throw(*args, **kwargs):
raise HTTP20Error("oops")

Expand All @@ -279,7 +279,7 @@ def throw(*args, **kwargs):
'processing request'
assert self.metrics.increment.called
assert self.metrics.increment.call_args[0][0] == \
'notification.bridge.connection.error'
'notification.bridge.error'
self.flushLoggedErrors()

@inlineCallbacks
Expand All @@ -300,7 +300,7 @@ def throw(*args, **kwargs):
'processing request'
assert self.metrics.increment.called
assert self.metrics.increment.call_args[0][0] == \
'notification.bridge.connection.error'
'notification.bridge.error'
self.flushLoggedErrors()

def test_too_many_connections(self):
Expand Down
8 changes: 8 additions & 0 deletions autopush/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ def _router_fail_err(self, fail, router_type=None, vapid=False, uaid=None):
# reporting a not found and they're mobile.
if exc.status_code in [404, 410] and router_type in [
'apns', 'fcm', 'adm']:
tags = self._base_tags.update({
"platform": router_type,
"reason": "unregistered",
})
self.metrics.increment(
"notification.bridge.error",
tags=tags)

self.db.router.drop_user(uaid)
self._router_response(exc, router_type, vapid)

Expand Down

0 comments on commit 37516a5

Please sign in to comment.