-
Notifications
You must be signed in to change notification settings - Fork 330
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
If register can used many times?【help wanted】 #628
Comments
Have you tried any of the options? The first one should start to fail the second time: prometheus-cpp/core/tests/registry_test.cc Lines 114 to 120 in 81e208c
You pay a penalty for calling auto f=prometheus::BuildGauge().Name(name).Register(*prometheus_registry);
while(true) {
f.Add(labels).Increment();
} This is the optimal case: auto f=prometheus::BuildGauge().Name(name).Register(*prometheus_registry);
auto some_specific_counter = f.Add(labels);
while(true) {
some_specific_counter.Increment();
} See in the example: prometheus-cpp/pull/tests/integration/sample_server.cc Lines 61 to 75 in 81e208c
|
Register's default param is Merge,so the same name and labels just return the existing one but not fail.
Here is part of my test
d1 cost time:1944940 microseconds,
|
If repeat call register leading to performance issues?
prometheus::BuildGauge().Name(name).Register(*prometheus_registry).Add(labels).Increment();
I have to register once and then add many times?
auto f=prometheus::BuildGauge().Name(name).Register(*prometheus_registry); while(true) { f.Add(labels).Increment(); }
The text was updated successfully, but these errors were encountered: