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 "mountpoint.h"
22 #include "options.h"
23 #include "statistics.h"
24 #include "util/single_copy.h"
25 
26 class MountPoint;
27 
28 namespace perf {
29 
30 // Return values of telemetry classes (including custom classes)
37 };
38 
39 // List of available custom telemetry classes
42 };
43 
45  FRIEND_TEST(T_TelemetryAggregator, EmptyCounters);
46  FRIEND_TEST(T_TelemetryAggregator, FailCreate);
47  FRIEND_TEST(T_TelemetryAggregator, ExtraFields_Tags);
48  FRIEND_TEST(T_TelemetryAggregator, UpdateCounters_WithExtraFields_Tags);
49 
50  public:
58  static TelemetryAggregator* Create(Statistics* statistics,
59  int send_rate,
60  OptionsManager *options_mgr,
61  MountPoint* mount_point,
62  const std::string &fqrn,
63  const TelemetrySelector type);
64  virtual ~TelemetryAggregator();
65 
69  void Spawn();
70 
71  protected:
73  const int send_rate_sec_;
76  pthread_t thread_telemetry_;
77  std::string fqrn_;
78  // State of constructed object. Used in custom telemetry classes to
79  // specify that the object was correctly constructed.
80  bool is_zombie_;
81 
82  uint64_t timestamp_;
83  std::map<std::string, int64_t> counters_;
84 
95  static void *MainTelemetry(void *data);
96 
101  TelemetryAggregator(Statistics* statistics, int send_rate_sec,
102  MountPoint* mount_point, const std::string &fqrn) :
103  statistics_(statistics),
104  send_rate_sec_(send_rate_sec),
105  mount_point_(mount_point),
106  fqrn_(fqrn),
107  is_zombie_(true),
108  timestamp_(0) {
109  pipe_terminate_[0] = pipe_terminate_[1] = -1;
110  memset(&thread_telemetry_, 0, sizeof(thread_telemetry_));
111  }
112 
120  virtual void PushMetrics() = 0;
121 
122  private:
128 };
129 
130 } // namespace perf
131 
132 #endif // CVMFS_TELEMETRY_AGGREGATOR_H_
virtual void PushMetrics()=0
TelemetryAggregator(Statistics *statistics, int send_rate_sec, MountPoint *mount_point, const std::string &fqrn)
static TelemetryAggregator * Create(Statistics *statistics, int send_rate, OptionsManager *options_mgr, MountPoint *mount_point, const std::string &fqrn, const TelemetrySelector type)
std::map< std::string, int64_t > counters_
static void * MainTelemetry(void *data)
FRIEND_TEST(T_TelemetryAggregator, EmptyCounters)