Repo-Init
 
Loading...
Searching...
No Matches
StatusTracker Class Reference

#include <Status.hpp>

Public Member Functions

 StatusTracker (const std::shared_ptr< prometheus::Registry > &reg, const std::string &name, uint64_t metricID=0)
 
void incrementActive ()
 
void decrementActive ()
 
void incrementSuccess ()
 
void incrementFail ()
 

Private Attributes

prometheus::Gauge * _activeCtr
 Active number of events.
 
prometheus::Counter * _totalCtr
 Total number of counters.
 
prometheus::Counter * _successCtr
 Number of success.
 
prometheus::Counter * _failedCtr
 Number of fail.
 

Detailed Description

Class for tracking the status of events and counting successes and failures.

Definition at line 9 of file Status.hpp.

Constructor & Destructor Documentation

◆ StatusTracker()

StatusTracker::StatusTracker ( const std::shared_ptr< prometheus::Registry > & reg,
const std::string & name,
uint64_t metricID = 0 )

Construct a new Status Tracker

Parameters
[in]regRegistry to prometheus
[in]nameName of the metric
[in]metricIDID to append to metric names

Definition at line 6 of file Status.cpp.

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}
prometheus::Gauge * _activeCtr
Active number of events.
Definition Status.hpp:11
prometheus::Counter * _failedCtr
Number of fail.
Definition Status.hpp:14
prometheus::Counter * _successCtr
Number of success.
Definition Status.hpp:13
prometheus::Counter * _totalCtr
Total number of counters.
Definition Status.hpp:12

Member Function Documentation

◆ decrementActive()

void StatusTracker::decrementActive ( )

Decrement number of current events

Definition at line 34 of file Status.cpp.

34{ _activeCtr->Decrement(); }
Here is the caller graph for this function:

◆ incrementActive()

void StatusTracker::incrementActive ( )

Increment number of current events

Definition at line 32 of file Status.cpp.

32{ _activeCtr->Increment(); }
Here is the caller graph for this function:

◆ incrementFail()

void StatusTracker::incrementFail ( )

Increment number of fail

Definition at line 46 of file Status.cpp.

47{
48 _failedCtr->Increment();
49 _totalCtr->Increment();
50 if (_activeCtr->Value() > 0)
51 {
52 _activeCtr->Decrement();
53 }
54}

◆ incrementSuccess()

void StatusTracker::incrementSuccess ( )

Increment number of success

Definition at line 36 of file Status.cpp.

37{
38 _successCtr->Increment();
39 _totalCtr->Increment();
40 if (_activeCtr->Value() > 0)
41 {
42 _activeCtr->Decrement();
43 }
44}

Member Data Documentation

◆ _activeCtr

prometheus::Gauge* StatusTracker::_activeCtr
private

Active number of events.

Definition at line 11 of file Status.hpp.

◆ _failedCtr

prometheus::Counter* StatusTracker::_failedCtr
private

Number of fail.

Definition at line 14 of file Status.hpp.

◆ _successCtr

prometheus::Counter* StatusTracker::_successCtr
private

Number of success.

Definition at line 13 of file Status.hpp.

◆ _totalCtr

prometheus::Counter* StatusTracker::_totalCtr
private

Total number of counters.

Definition at line 12 of file Status.hpp.


The documentation for this class was generated from the following files: