-
Notifications
You must be signed in to change notification settings - Fork 246
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
Use the Prometheus Registry behind Mutex to share mutable references #2518
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered having simply Option<&mut Registry> but since we eventually use Arc<Mutex for RegistryAdapter and the mutable reference will need to be around longer (since it is running in background task), it's better to have Arc<Mutex at Registry and remove it from RegistryAdapter.
I'm not sure it is better. What background task are you talking about exactly?
In fact I don't believe Arc<Mutex<SharedRegistry>>
is necessary in the first place, it should be changed to Arc<SharedRegitry>
since I do not see or expect any mutation there. Also unsafe
usage there is not necessary either and should be removed.
I am talking about the Reason why we have two prometheus worker is because the node's prometheus worker is started inside the service and I cannot customize/combine it. |
Maybe using |
To be clear, what you are proposing works. However it is a hack on top of another hack and increases technical debt, which is why I'm looking for ways to improve situation instead and upgrade architecture to something better.
Not sure what is
That is incorrect as well, it should be pulled out of there into So we need to pull it out of the config, but leave to Also we can try to construct Substrate's registry explicitly ourselves, but need to check carefully whether something in Substrate internals tries to access registry via config (I hope there isn't anything, but I didn't check). Then we can avoid having prometheus config.
Should be strictly worse unless under lock contention, which I don't expect to be the case in this case. Though for the same exact reason it doesn't matter what is used. |
Apart from Okay. Let's improve the architecture here, I can work on this. |
Right, you just need to pass |
Description
This PR modifies Prometheus registry usage to be behind
Arc<Mutex
. This allows clients like Pulsar to use one registry for bothFarmer
andNode
instance.I considered having simply
Option<&mut Registry>
but since we eventually useArc<Mutex
forRegistryAdapter
and the mutable reference will need to be around longer (since it is running in background task), it's better to haveArc<Mutex
at Registry and remove it fromRegistryAdapter
.Code contributor checklist: