You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you provide working example how create summary family ?
I tried to do something like this :
struct SummaryWithQuantiles {
prometheus::Family<prometheus::Summary> family;
std::vector<double> quantiles;
// Constructor to initialize the family member
SummaryWithQuantiles(const prometheus::Family<prometheus::Summary>& fam, const std::vector<double>& q)
: family(fam), quantiles(q) {}
};
void PrometheusInterface::CreateSummary(const std::string& name, const std::string& help, const std::vector<double>& quantiles) {
const std::chrono::milliseconds max_age(3600000); // 1 hour
const int age_buckets = 5;
// Create the summary family
auto summary_family = prometheus::BuildSummary()
.Name(name)
.Help(help)
.MaxAge(max_age)
.AgeBuckets(age_buckets)
.Register(*mRegisterShPtr);
// Create a custom structure to hold the summary family and quantiles
SummaryWithQuantiles summaryWithQuantiles(summary_family, quantiles);
// Store the summary with quantiles in the map
mSummaries[name] = summaryWithQuantiles;
}
void PrometheusInterface::ObserveSummary(const std::string& name, double value, const std::map<std::string, std::string>& labels) {
if (mSummaries.find(name) != mSummaries.end()) {
auto& summaryWithQuantiles = mSummaries[name];
for (double quantile : summaryWithQuantiles.quantiles) {
summaryWithQuantiles.family.Add(labels).Quantile(quantile).Observe(value);
}
}
else {
LOG4CXX_ERROR(log4cxx::Logger::getLogger("PrometheusInterface"), Format("Summary metric %s was not created before, so it will not be observed!", name.c_str()));
}
}
but it is not compiled .
The text was updated successfully, but these errors were encountered:
Can you provide working example how create summary family ?
I tried to do something like this :
but it is not compiled .
The text was updated successfully, but these errors were encountered: