Loading...
Searching...
No Matches
summary.h
#pragma once
#include <chrono>
#include <cstdint>
#include <mutex>
#include <vector>
#include "prometheus/client_metric.h"
#include "prometheus/detail/builder.h" // IWYU pragma: export
#include "prometheus/detail/ckms_quantiles.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/detail/time_window_quantiles.h"
#include "prometheus/metric_type.h"
namespace prometheus {
class PROMETHEUS_CPP_CORE_EXPORT Summary {
public:
using Quantiles = std::vector<detail::CKMSQuantiles::Quantile>;
static const MetricType metric_type{MetricType::Summary};
Summary(const Quantiles& quantiles,
std::chrono::milliseconds max_age = std::chrono::seconds{60},
int age_buckets = 5);
void Observe(double value);
ClientMetric Collect() const;
private:
const Quantiles quantiles_;
mutable std::mutex mutex_;
std::uint64_t count_;
double sum_;
detail::TimeWindowQuantiles quantile_values_;
};
PROMETHEUS_CPP_CORE_EXPORT detail::Builder<Summary> BuildSummary();
} // namespace prometheus
prometheus::Summary
A summary metric samples observations over a sliding window of time.
Definition summary.h:41
prometheus::ClientMetric
Definition client_metric.h:12