Repo-Init
 
Loading...
Searching...
No Matches
Status.cpp
Go to the documentation of this file.
1#include "metrics/Status.hpp"
2
3#include <prometheus/counter.h>
4#include <prometheus/gauge.h>
5
6StatusTracker::StatusTracker(const std::shared_ptr<prometheus::Registry> &reg, const std::string &name,
7 uint64_t metricID)
8{
9 // Register values
10 _activeCtr = &prometheus::BuildGauge()
11 .Name(name + "_active_event_ctr_" + std::to_string(metricID))
12 .Help("Currently active number of events of " + name)
13 .Register(*reg)
14 .Add({});
15 _totalCtr = &prometheus::BuildCounter()
16 .Name(name + "_total_event_ctr_" + std::to_string(metricID))
17 .Help("Total occurrences of " + name)
18 .Register(*reg)
19 .Add({});
20 _successCtr = &prometheus::BuildCounter()
21 .Name(name + "_success_event_ctr_" + std::to_string(metricID))
22 .Help("Successful events of " + name)
23 .Register(*reg)
24 .Add({});
25 _failedCtr = &prometheus::BuildCounter()
26 .Name(name + "_fail_event_ctr_" + std::to_string(metricID))
27 .Help("Failed events of " + name)
28 .Register(*reg)
29 .Add({});
30}
31
33
35
37{
38 _successCtr->Increment();
39 _totalCtr->Increment();
40 if (_activeCtr->Value() > 0)
41 {
42 _activeCtr->Decrement();
43 }
44}
45
47{
48 _failedCtr->Increment();
49 _totalCtr->Increment();
50 if (_activeCtr->Value() > 0)
51 {
52 _activeCtr->Decrement();
53 }
54}
void incrementActive()
Definition Status.cpp:32
prometheus::Gauge * _activeCtr
Active number of events.
Definition Status.hpp:11
void incrementSuccess()
Definition Status.cpp:36
void incrementFail()
Definition Status.cpp:46
StatusTracker(const std::shared_ptr< prometheus::Registry > &reg, const std::string &name, uint64_t metricID=0)
Definition Status.cpp:6
prometheus::Counter * _failedCtr
Number of fail.
Definition Status.hpp:14
void decrementActive()
Definition Status.cpp:34
prometheus::Counter * _successCtr
Number of success.
Definition Status.hpp:13
prometheus::Counter * _totalCtr
Total number of counters.
Definition Status.hpp:12