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

Prometheus metrics #174

Merged
merged 11 commits into from
May 16, 2024
Merged

Prometheus metrics #174

merged 11 commits into from
May 16, 2024

Conversation

kostekIV
Copy link
Contributor

We are using your proxy for quite some time now and it works great for us, thank you for this :)
We needed metrics for our internal reporting & stuff so quite a while ago I have added them to our fork of subway. I also saw you have them marked as a TODO in the readme. So this pr is a work I have already done to introduce prometheus metrics to subway. If you think this would be nice to have here you go, of course Im happy to go through rounds of review :)

This pr contains 2 major changes.

  1. jsonrpsee version bump
  2. Adding prometheus metrics for methods, ws/http connections count and cache + startup of the prometheus exporter

To see changes related only to jsonrpsee bump look at the commit update jsonrpsee and simiraly to see chanegs related only to prometheus inclusion take a look at the Add prometheus metrics

Why jsonrpsee bump?

While it was not strictly need, without it the metrics related to the ws connection would be nearly impossible to write (and for sure it would be quite painfull to do).
Also since I did not have an access to your fork of the jsonrpsee this was the quickest thing I could do to make those changes.

What kind of metrics there are?

So there is ws/http counter metrics for open/closed sessions. Also metrics for the methods that are based on the ones that are used in the substrate - same names etc. Additionally metrics for cache misses per method.

Cc @xlc

@xlc
Copy link
Member

xlc commented May 10, 2024

Thanks for the PR! Will take a review next week.

@xlc
Copy link
Member

xlc commented May 10, 2024

And it will be great if you can get the CI pass meanwhile. I have updated the toolchain version on master.

Some(p) if p.is_empty() => None,
p => p,
};
let registry = Registry::new_custom(prefix, labels).expect("Can't happen");
Copy link
Member

Choose a reason for hiding this comment

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

why it can't fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only can fail if the prefix is equal to Some(p) where p.is_mepty() and we take care of that in the match above

Copy link
Member

Choose a reason for hiding this comment

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

can you explain it in the expect? otherwise the next reader is likely going to have the same question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I think now it should be better

src/extensions/prometheus/mod.rs Outdated Show resolved Hide resolved
src/extensions/prometheus/mod.rs Outdated Show resolved Hide resolved
src/extensions/server/prometheus.rs Outdated Show resolved Hide resolved
@xlc xlc merged commit 8e8247c into AcalaNetwork:master May 16, 2024
1 check passed
@kostekIV kostekIV deleted the metrics branch May 16, 2024 06:55
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