CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
telemetry_aggregator.h
Go to the documentation of this file.
1 
9 #ifndef CVMFS_TELEMETRY_AGGREGATOR_H_
10 #define CVMFS_TELEMETRY_AGGREGATOR_H_
11 
12 #include <pthread.h>
13 #include <stdint.h>
14 
15 #include <cstring>
16 #include <map>
17 #include <string>
18 #include <vector>
19 
20 #include "gtest/gtest_prod.h"
21 #include "options.h"
22 #include "statistics.h"
23 #include "util/single_copy.h"
24 
25 namespace perf {
26 
27 // Return values of telemetry classes (including custom classes)
34 };
35 
36 // List of available custom telemetry classes
39 };
40 
42  FRIEND_TEST(T_TelemetryAggregator, EmptyCounters);
43  FRIEND_TEST(T_TelemetryAggregator, FailCreate);
44  FRIEND_TEST(T_TelemetryAggregator, ExtraFields_Tags);
45  FRIEND_TEST(T_TelemetryAggregator, UpdateCounters_WithExtraFields_Tags);
46 
47  public:
55  static TelemetryAggregator* Create(Statistics* statistics,
56  int send_rate,
57  OptionsManager *options_mgr,
58  const std::string &fqrn,
59  const TelemetrySelector type);
60  virtual ~TelemetryAggregator();
61 
65  void Spawn();
66 
67  protected:
69  const int send_rate_sec_;
71  pthread_t thread_telemetry_;
72  std::string fqrn_;
73  // State of constructed object. Used in custom telemetry classes to
74  // specify that the object was correctly constructed.
75  bool is_zombie_;
76 
77  uint64_t timestamp_;
78  std::map<std::string, int64_t> counters_;
79 
90  static void *MainTelemetry(void *data);
91 
96  TelemetryAggregator(Statistics* statistics, int send_rate_sec,
97  const std::string &fqrn) :
98  statistics_(statistics),
99  send_rate_sec_(send_rate_sec),
100  fqrn_(fqrn),
101  is_zombie_(true),
102  timestamp_(0) {
103  pipe_terminate_[0] = pipe_terminate_[1] = -1;
104  memset(&thread_telemetry_, 0, sizeof(thread_telemetry_));
105  }
106 
114  virtual void PushMetrics() = 0;
115 };
116 
117 } // namespace perf
118 
119 #endif // CVMFS_TELEMETRY_AGGREGATOR_H_
virtual void PushMetrics()=0
static TelemetryAggregator * Create(Statistics *statistics, int send_rate, OptionsManager *options_mgr, const std::string &fqrn, const TelemetrySelector type)
std::map< std::string, int64_t > counters_
TelemetryAggregator(Statistics *statistics, int send_rate_sec, const std::string &fqrn)
static void * MainTelemetry(void *data)
FRIEND_TEST(T_TelemetryAggregator, EmptyCounters)