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 metrics: bridge_matrix_api_calls and …_failed #2

Merged
merged 13 commits into from
Nov 12, 2021

Conversation

jaller94
Copy link

  • Add the metrics bridge_matrix_api_calls and bridge_matrix_api_calls_failed

@jaller94 jaller94 marked this pull request as draft November 10, 2021 12:33
Comment on lines 19 to 22
API_CALLS = Counter("bridge_matrix_api_calls",
"The number of Matrix client API calls made", ("update_type",))
API_CALLS_FAILED = Counter("bridge_matrix_api_calls_failed",
"The number of Matrix client API calls which failed", ("update_type",))
Copy link
Author

Choose a reason for hiding this comment

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

Do these need to be imported in a web endpoint function or does a creation of Counter() already add the metric to a Prometheus endpoint?

Copy link
Member

Choose a reason for hiding this comment

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

It's magic, you don't need to do anything :)

@jaller94
Copy link
Author

Possible improvements (possibly in another PR, given the urgency):

  • Cover other parts of the API, not just events.py.
  • Write a wrapper function as the current code includes a lot of repetition.

@jaller94 jaller94 marked this pull request as ready for review November 10, 2021 14:00
@jaller94 jaller94 requested a review from Half-Shot November 10, 2021 14:00
@Half-Shot
Copy link
Member

Write a wrapper function as the current code includes a lot of repetition.

I feel like there has gotta be a way to do this with attributes in python

Copy link
Member

@Half-Shot Half-Shot left a comment

Choose a reason for hiding this comment

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

Code looks great, if it works we can shippit

@jaller94 jaller94 merged commit 0edf2df into master Nov 12, 2021
@Half-Shot
Copy link
Member

Ah, @jaller94 can you also open this upstream to mautrix as well?

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.

2 participants