#include "metrics.h"
#include <assert.h>
+#include <math.h>
#include <algorithm>
+#include <chrono>
#include <locale>
#include <sstream>
using namespace std;
+using namespace std::chrono;
Metrics global_metrics;
+double get_timestamp_for_metrics()
+{
+ return duration<double>(system_clock::now().time_since_epoch()).count();
+}
+
namespace {
string serialize_name(const string &name, const vector<pair<string, string>> &labels)
}
}
+void Histogram::init_geometric(double min, double max, size_t num_buckets)
+{
+ this->num_buckets = num_buckets;
+ buckets.reset(new Bucket[num_buckets]);
+ for (size_t i = 0; i < num_buckets; ++i) {
+ buckets[i].val = min * pow(max / min, double(i) / (num_buckets - 1));
+ }
+}
+
void Histogram::count_event(double val)
{
Bucket ref_bucket;