| 119 | namespace Metrics |
| 120 | { |
| 121 | class Counter : public detail::BaseMetrics |
| 122 | { |
| 123 | using super_type = detail::BaseMetrics; |
| 124 | using self_type = Counter; |
| 125 | |
| 126 | public: |
| 127 | Counter(const cripts::string_view &name) : super_type(name) { _initialize(ts::Metrics::Counter::create(name)); } |
| 128 | |
| 129 | // Counters can only increment, so lets produce some nice compile time erorrs too |
| 130 | void Decrement(int64_t) = delete; |
| 131 | void Setter(int64_t val) = delete; |
| 132 | |
| 133 | template <typename T> |
| 134 | void |
| 135 | Decrement(T) |
| 136 | { |
| 137 | static_assert(std::is_same_v<T, int64_t>, "A Metric::Counter can only use Increment(), consider Metric::Gauge instead?"); |
| 138 | } |
| 139 | |
| 140 | template <typename T> |
| 141 | void |
| 142 | Setter(T) |
| 143 | { |
| 144 | static_assert(std::is_same_v<T, int64_t>, "A Metric::Counter can not be set to a value), consider Metric::Gauge instead?"); |
| 145 | } |
| 146 | |
| 147 | static self_type * |
| 148 | Create(const cripts::string_view &name) |
| 149 | { |
| 150 | auto *ret = new self_type(name); |
| 151 | auto id = ts::Metrics::Counter::create(name); |
| 152 | |
| 153 | ret->_initialize(id); |
| 154 | |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | }; // class Counter |
| 159 | |
| 160 | class Gauge : public detail::BaseMetrics |
| 161 | { |