This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-zerotierone/ext/prometheus-cpp-lite-1.0/core/include/prometheus/builder.h

35 lines
704 B
C
Raw Normal View History

#pragma once
#include <string>
#include <map>
#include "registry.h"
namespace prometheus {
template <typename CustomMetric>
class Builder {
Family::Labels labels_;
std::string name_;
std::string help_;
public:
Builder& Labels(const std::map<const std::string, const std::string>& labels) {
labels_ = labels;
return *this;
}
Builder& Name(const std::string& name) {
name_ = name;
return *this;
}
Builder& Help(const std::string& help) {
help_ = help;
return *this;
}
CustomFamily<CustomMetric>& Register(Registry& registry) {
return registry.Add<CustomFamily<CustomMetric>>(name_, help_, labels_);
}
};
}