mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
peer latency histogram actually works now
This commit is contained in:
parent
f548905db4
commit
d43ead5a71
4 changed files with 24 additions and 13 deletions
|
@ -28,15 +28,9 @@ namespace prometheus {
|
|||
/// a data race.
|
||||
template <typename Value_ = uint64_t>
|
||||
class Histogram : public Metric {
|
||||
|
||||
using BucketBoundaries = std::vector<Value_>;
|
||||
|
||||
const BucketBoundaries bucket_boundaries_;
|
||||
std::vector<Counter<Value_>> bucket_counts_;
|
||||
Gauge<Value_> sum_;
|
||||
|
||||
public:
|
||||
using Value = Value_;
|
||||
using BucketBoundaries = std::vector<Value_>;
|
||||
using Family = CustomFamily<Histogram<Value>>;
|
||||
|
||||
static const Metric::Type static_type = Metric::Type::Histogram;
|
||||
|
@ -69,7 +63,7 @@ namespace prometheus {
|
|||
bucket_boundaries_.begin(),
|
||||
std::find_if(
|
||||
std::begin(bucket_boundaries_), std::end(bucket_boundaries_),
|
||||
[value](const double boundary) { return boundary >= value; })));
|
||||
[value](const Value boundary) { return boundary >= value; })));
|
||||
sum_.Increment(value);
|
||||
bucket_counts_[bucket_index].Increment();
|
||||
}
|
||||
|
@ -110,7 +104,7 @@ namespace prometheus {
|
|||
bucket.cumulative_count = cumulative_count;
|
||||
bucket.upper_bound = (i == bucket_boundaries_.size()
|
||||
? std::numeric_limits<double>::infinity()
|
||||
: bucket_boundaries_[i]);
|
||||
: static_cast<double>(bucket_boundaries_[i]));
|
||||
metric.histogram.bucket.push_back(std::move(bucket));
|
||||
}
|
||||
metric.histogram.sample_count = cumulative_count;
|
||||
|
@ -119,6 +113,12 @@ namespace prometheus {
|
|||
return metric;
|
||||
}
|
||||
|
||||
private:
|
||||
const BucketBoundaries bucket_boundaries_;
|
||||
std::vector<Counter<Value_>> bucket_counts_;
|
||||
Gauge<Value_> sum_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/// \brief Return a builder to configure and register a Histogram metric.
|
||||
|
|
|
@ -177,8 +177,19 @@ namespace ZeroTier {
|
|||
{ "zt_network_outgoing_packets", "number of outgoing packets per network" };
|
||||
|
||||
// PeerMetrics
|
||||
prometheus::CustomFamily<prometheus::Histogram<uint64_t>> peer_latency
|
||||
{ "zt_peer_latency", "peer latency (ms)", {}};
|
||||
prometheus::CustomFamily<prometheus::Histogram<uint64_t>> &peer_latency =
|
||||
prometheus::Builder<prometheus::Histogram<uint64_t>>()
|
||||
.Name("zt_peer_latency")
|
||||
.Help("peer latency (ms)")
|
||||
.Register(prometheus::simpleapi::registry);
|
||||
/* prometheus::CustomFamily<prometheus::Histogram<uint64_t>>::Build(
|
||||
prometheus::simpleapi::registry,
|
||||
"zt_peer_latency",
|
||||
"peer latency (ms)",
|
||||
{}
|
||||
);
|
||||
*/ //{ prometheus::Metric::Type::Histogram, "zt_peer_latency", "peer latency (ms)", {}};
|
||||
|
||||
prometheus::simpleapi::gauge_family_t peer_path_count
|
||||
{ "zt_peer_path_count", "number of paths to peer" };
|
||||
prometheus::simpleapi::counter_family_t peer_incoming_packets
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace ZeroTier {
|
|||
extern prometheus::simpleapi::counter_family_t network_outgoing_packets;
|
||||
|
||||
// Peer Metrics
|
||||
extern prometheus::CustomFamily<prometheus::Histogram<uint64_t>> peer_latency;
|
||||
extern prometheus::CustomFamily<prometheus::Histogram<uint64_t>> &peer_latency;
|
||||
extern prometheus::simpleapi::gauge_family_t peer_path_count;
|
||||
extern prometheus::simpleapi::counter_family_t peer_incoming_packets;
|
||||
extern prometheus::simpleapi::counter_family_t peer_outgoing_packets;
|
||||
|
|
|
@ -600,7 +600,7 @@ private:
|
|||
|
||||
SharedPtr<Bond> _bond;
|
||||
|
||||
prometheus::Histogram<uint64_t> _peer_latency;
|
||||
prometheus::Histogram<uint64_t> &_peer_latency;
|
||||
prometheus::simpleapi::gauge_metric_t _alive_path_count;
|
||||
prometheus::simpleapi::gauge_metric_t _dead_path_count;
|
||||
prometheus::simpleapi::counter_metric_t _incoming_packet;
|
||||
|
|
Loading…
Add table
Reference in a new issue