Peer metrics (#1995)
* Adding peer metrics still need to be wired up for use * per peer packet metrics * Fix crash from bad instantiation of histogram * separate alive & dead path counts * Add peer metric update block * add peer latency values in doPingAndKeepalive * prevent deadlock * peer latency histogram actually works now * cleanup * capture counts of packets to specific peers --------- Co-authored-by: Joseph Henry <joseph.henry@zerotier.com>
This commit is contained in:
parent
925599cab0
commit
74dc41c7c7
5 changed files with 102 additions and 53 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue