2
0

simpleapi_example.cpp 772 B

1234567891011121314151617181920212223242526
  1. #include <prometheus/simpleapi.h>
  2. int main() {
  3. using namespace prometheus::simpleapi;
  4. counter_family_t family { "simple_family", "simple family example" };
  5. counter_metric_t metric1 { family.Add({{"name", "counter1"}}) };
  6. counter_metric_t metric2 { family.Add({{"name", "counter2"}}) };
  7. counter_metric_t metric3 { "simple_counter_1", "simple counter 1 without labels example" };
  8. counter_metric_t metric4 { "simple_counter_2", "simple counter 2 without labels example" };
  9. for (;; ) {
  10. std::this_thread::sleep_for(std::chrono::seconds(1));
  11. const int random_value = std::rand();
  12. if (random_value & 1) metric1++;
  13. if (random_value & 2) metric2++;
  14. if (random_value & 4) metric3++;
  15. if (random_value & 8) metric4++;
  16. }
  17. //return 0;
  18. }