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

Commit

Permalink
bug: Elevate GCM reported error states
Browse files Browse the repository at this point in the history
Increase reporting priority for GCM errors so that they are logged to
Kibana. Made some messaging more unique and descriptive of actual case.

closes: #505
  • Loading branch information
jrconlin authored and bbangert committed Jul 13, 2016
1 parent 1997372 commit 0408053
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions autopush/router/gcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,19 @@ def _process_reply(self, reply):
# for reg_id, msg_id in reply.success.items():
# updates
for old_id, new_id in reply.canonical.items():
self.log.debug("GCM id changed : {old} => {new}",
old=old_id, new=new_id)
self.log.info("GCM id changed : {old} => {new}",
old=old_id, new=new_id)
self.metrics.increment("updates.client.bridge.gcm.failed.rereg",
self._base_tags)
return RouterResponse(status_code=503,
response_body="Please try request again.",
router_data=dict(token=new_id))
# naks:
# uninstall:
for reg_id in reply.not_registered:
self.log.debug("GCM no longer registered: %s" % reg_id)
self.metrics.increment("updates.client.bridge.gcm.failed.unreg",
self._base_tags)
self.log.info("GCM no longer registered: %s" % reg_id)
return RouterResponse(
status_code=410,
response_body="Endpoint requires client update",
Expand All @@ -138,14 +142,21 @@ def _process_reply(self, reply):

# for reg_id, err_code in reply.failed.items():
if len(reply.failed.items()) > 0:
self.log.debug("GCM failures: {failed()}",
failed=lambda: json.dumps(reply.failed.items()))
self.metrics.increment("updates.client.bridge.gcm.failed.failure",
self._base_tags)
self.log.critical("GCM failures: {failed()}",
failed=lambda: json.dumps(reply.failed.items()))
raise RouterException("GCM failure to deliver", status_code=503,
response_body="Please try request later.")

# retries:
if reply.needs_retry():
raise RouterException("GCM failure to deliver", status_code=503,
self.log.warn("GCM retry requested: {failed()}",
failed=lambda: json.dumps(reply.failed.items()))
self.metrics.increment("updates.client.bridge.gcm.failed.retry",
self._base_tags)
raise RouterException("GCM failure to deliver, retry",
status_code=503,
response_body="Please try request later.")

self.metrics.increment("updates.client.bridge.gcm.succeeded",
Expand Down

0 comments on commit 0408053

Please sign in to comment.