Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prometheus metrics for number of badge update pushes. #4709

Merged
merged 2 commits into from Feb 22, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+26 −8
Diff settings

Always

Just for now

Copy path View file
@@ -0,0 +1 @@
Add prometheus metrics for number of badge update pushes.
Copy path View file
@@ -32,9 +32,25 @@

logger = logging.getLogger(__name__)

http_push_processed_counter = Counter("synapse_http_httppusher_http_pushes_processed", "")
http_push_processed_counter = Counter(
"synapse_http_httppusher_http_pushes_processed",
"Number of push notifications successfully sent",
)

http_push_failed_counter = Counter("synapse_http_httppusher_http_pushes_failed", "")
http_push_failed_counter = Counter(
"synapse_http_httppusher_http_pushes_failed",
"Number of push notifications which failed",
)

http_badges_processed_counter = Counter(
"synapse_http_httppusher_badge_updates_processed",
"Number of badge updates successfully sent",
)

http_badges_failed_counter = Counter(
"synapse_http_httppusher_badge_updates_processed",
"Number of badge updates successfully sent",
)


class HttpPusher(object):
@@ -346,6 +362,10 @@ def dispatch_push(self, event, tweaks, badge):

@defer.inlineCallbacks
def _send_badge(self, badge):
"""
Args:
badge (int): number of unread messages
"""
logger.info("Sending updated badge count %d to %s", badge, self.name)
d = {
'notification': {
@@ -366,14 +386,11 @@ def _send_badge(self, badge):
}
}
try:
resp = yield self.http_client.post_json_get_json(self.url, d)
yield self.http_client.post_json_get_json(self.url, d)
http_badges_processed_counter.inc()
except Exception as e:
logger.warning(
"Failed to send badge count to %s: %s %s",
self.name, type(e), e,
)
defer.returnValue(False)
rejected = []
if 'rejected' in resp:
rejected = resp['rejected']

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Feb 21, 2019

Member

Isn't this important?

This comment has been minimized.

Copy link
@richvdh

richvdh Feb 21, 2019

Author Member

well, maybe, but we don't use it.

This comment has been minimized.

Copy link
@erikjohnston
defer.returnValue(rejected)
http_badges_failed_counter.inc()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.