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

Unify Prometheus library with libp2p #12699

Open
nazar-pc opened this issue Nov 14, 2022 · 6 comments
Open

Unify Prometheus library with libp2p #12699

nazar-pc opened this issue Nov 14, 2022 · 6 comments

Comments

@nazar-pc
Copy link
Contributor

Substrate currently uses prometheus library, while libp2p uses prometheus-client, which is now the official Rust library, see libp2p change: libp2p/rust-libp2p#2442

In our node we have both Substrate and another libp2p-based library used and it would be ideal to push all metrics into the same endpoint, but due to completely different libraries used this is not currently possible.

Please consider switching to prometheus-client library in Substrate, it will likely receive more attention going forward.

@tomaka
Copy link
Contributor

tomaka commented Nov 14, 2022

My two cents: I find the entire Prometheus code extremely over-engineered. The Prometheus format is dead simple, and I don't understand why we even need a third party library for that.
All the Prometheus libraries are just a glorified Arc<Mutex<HashMap<String, u64>>> with a function to turn it into the text format linked above.

@nazar-pc
Copy link
Contributor Author

If you write an ergonomic wrapper for those hashmaps and serializer to text format you'll end up with a custom library anyway, so might as well use something off-the-shelf. I think the biggest value is in more complex kinds of metrics like histograms and summaries, not sure how widely used they are in Substrate though.

@nazar-pc
Copy link
Contributor Author

If someone was do tackle the migration, I'm wondering what are the chances of getting it upstreamed in Substrate.
We'd really like to unify monitoring libraries in our project between libp2p, Substrate and otherwise.

@bkchr
Copy link
Member

bkchr commented Dec 18, 2022

I mean someone can tackle this issue. Probably not really complicated.

We'd really like to unify monitoring libraries in our project between libp2p, Substrate and otherwise.

However, I don't get this? Prometheus is some standard, so both libraries are probably already compatible and not change your monitoring?

@nazar-pc
Copy link
Contributor Author

/monitoring endpoint in the end just prints a bunch of text, that is the end result library provides.
The challenge is that by having several different libraries we need to support both throughout the stack and concatenate the output rather than using the same instance everywhere (and having ability to do things like prefixing metrics for different parts of the app making them distinct).

@bkchr
Copy link
Member

bkchr commented Dec 18, 2022

Okay, thank you for the explanation!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants