comparison Core/MetricsRegistry.h @ 3176:784bbb03fb54

new metrics: orthanc_rest_api_active_requests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Jan 2019 18:07:41 +0100
parents 8ea7c4546c3a
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3175:574890d14c92 3176:784bbb03fb54
109 109
110 // https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format 110 // https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
111 void ExportPrometheusText(std::string& s); 111 void ExportPrometheusText(std::string& s);
112 112
113 113
114 class SharedMetrics : public boost::noncopyable
115 {
116 private:
117 boost::mutex mutex_;
118 MetricsRegistry& registry_;
119 std::string name_;
120 float value_;
121
122 public:
123 SharedMetrics(MetricsRegistry& registry,
124 const std::string& name,
125 MetricsType type) :
126 registry_(registry),
127 name_(name),
128 value_(0)
129 {
130 }
131
132 void Add(float delta);
133 };
134
135
136 class ActiveCounter : public boost::noncopyable
137 {
138 private:
139 SharedMetrics& metrics_;
140
141 public:
142 ActiveCounter(SharedMetrics& metrics) :
143 metrics_(metrics)
144 {
145 metrics_.Add(1);
146 }
147
148 ~ActiveCounter()
149 {
150 metrics_.Add(-1);
151 }
152 };
153
154
114 class Timer : public boost::noncopyable 155 class Timer : public boost::noncopyable
115 { 156 {
116 private: 157 private:
117 MetricsRegistry& registry_; 158 MetricsRegistry& registry_;
118 std::string name_; 159 std::string name_;