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 8 of file Status.cpp.

10{
11 // Register values
12 _activeCtr = &prometheus::BuildGauge()
13 .Name(std::format("{}{}{}", name, "_active_event_ctr_", metricID))
14 .Help("Currently active number of events of " + name)
15 .Register(*reg)
16 .Add({});
17 _totalCtr = &prometheus::BuildCounter()
18 .Name(std::format("{}{}{}", name, "_total_event_ctr_", metricID))
19 .Help("Total occurrences of " + name)
20 .Register(*reg)
21 .Add({});
22 _successCtr = &prometheus::BuildCounter()
23 .Name(std::format("{}{}{}", name, "_success_event_ctr_", metricID))
24 .Help("Successful events of " + name)
25 .Register(*reg)
26 .Add({});
27 _failedCtr = &prometheus::BuildCounter()
28 .Name(std::format("{}{}{}", name, "_fail_event_ctr_", metricID))
29 .Help("Failed events of " + name)
30 .Register(*reg)
31 .Add({});
32}
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 36 of file Status.cpp.

36{ _activeCtr->Decrement(); }

◆ incrementActive()

void StatusTracker::incrementActive ( )

Increment number of current events

Definition at line 34 of file Status.cpp.

34{ _activeCtr->Increment(); }

◆ incrementFail()

void StatusTracker::incrementFail ( )

Increment number of fail

Definition at line 48 of file Status.cpp.

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

◆ incrementSuccess()

void StatusTracker::incrementSuccess ( )

Increment number of success

Definition at line 38 of file Status.cpp.

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

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: