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 metric for sygnal_inflight_request_limit_drop #146

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

reivilibre
Copy link
Contributor

No description provided.

@reivilibre reivilibre requested a review from a team August 6, 2020 10:33
@@ -142,6 +144,13 @@ class ConcurrencyLimitedPushkin(Pushkin):

UNDERSTOOD_CONFIG_FIELDS = {"inflight_request_limit"}

RATELIMITING_DROPPED_REQUESTS = Counter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: if there are two pushkins (say, for GCM and APNS), do they both correctly refer to the same instance of Counter ? or do they each get their own instance (which will probably confuse the prometheus lib)?

(I can never quite remember how class-level attributes work)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should get the same one. I wasn't 100% sure that's what was wanted, but I think it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was/is that the class attribute is initialised when the class declaration is executed, and that attribute stays with the class.

Note it is always referred to as ConcurrencyLimitedPushkin.RATELIMITING_DROPPED_REQUESTS, so it would always act like a namespaced global.

I didn't know whether subclasses would get access to it (not that it matters, since we access the field statically every time and not through self or cls), so I tried it:

oli@bbm-neon:~$ python3
Python 3.6.9 (default, Jul 17 2020, 12:50:27) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class X:
...     bob = []
... 
>>> class Y(X):
...     pass
... 
>>> class Z(X):
...     pass
... 
>>> id(Y.bob)
140481390301896
>>> id(X.bob)
140481390301896
>>> id(Z.bob)
140481390301896

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and to answer the question, yes this is intended — the pushkin is distinguished by the pushkin label, as this is what Prometheus understands)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your example, even doing the following should return the same thing:

id(Y().bob)

Doesn't matter if you access it via the class name or not (although I think it is clearer to access class-level variables that way).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your example, even doing the following should return the same thing:

id(Y().bob)

Doesn't matter if you access it via the class name or not (although I think it is clearer to access class-level variables that way).

Yes you are right (and I suspected so), but my experience from Java is that 'access static vars by class name, even if you can do it by instance' :)

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@reivilibre reivilibre merged commit 53530be into master Aug 6, 2020
@reivilibre reivilibre deleted the rei/inflight_limiting_metrics branch August 6, 2020 14:53
awesome-michael added a commit to Awesome-Technologies/sygnal that referenced this pull request Oct 1, 2020
Features
--------

- Add the ability to configure custom FCM options, which is necessary for using iOS with Firebase. ([\matrix-org#145](matrix-org#145))
- Add a Prometheus metric (`sygnal_inflight_request_limit_drop`) that shows the number of notifications dropped due to exceeding the in-flight concurrent request limit. ([\matrix-org#146](matrix-org#146))

Change-Id: Ia78c1a0c85765c29343a986ac7e7e93ca83b4b83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants