Conversation
Move metric descriptiions to package vars to avoid allocating them every time `NewCPUFreqCollector()` is called. Signed-off-by: Ben Kochie <superq@gmail.com>
|
CC @britcey, I don't think this will help your situation, unless you're using the |
|
Isn't I don't really see how this is any significant optimization. |
|
@SuperQ hrmm @dswarbrick is right, why this change? |
|
No, this can be called on every scrape if you call it with the |
|
Ah I see.. maybe then we should go through all collectors to look for similiar saving. |
Oof. That's going to result in a LOT of package-level variables pollution. |
|
@dswarbrick Yeah I'm worrying about that as well. I wanted to refactor the collector package for a while and move related functionality to subpackages but since nobody is paying me currently for anything prometheus related, I won't get to that anytime soon.. |
|
Eh, I don't see the package vars for the collector Descs as a big deal. I think we should migrate collectors to this new pattern. It's not a huge performance change for most users, but it would be good to keep things consistent. We actually discussed this pattern as part of our refactoring the postgres_exporter to use a similar collector package. We decided to go with package level Desc vars to avoid any reallocaiton. |
Move metric descriptiions to package vars to avoid allocating them every time
NewCPUFreqCollector()is called.Signed-off-by: Ben Kochie superq@gmail.com