Finish metrics design, I think
This commit is contained in:
@@ -76,15 +76,7 @@ struct LabelsKey {
|
||||
namespace std {
|
||||
template <> struct hash<metric::LabelsKey> {
|
||||
std::size_t operator()(const metric::LabelsKey &k) const {
|
||||
thread_local std::vector<size_t> parts;
|
||||
parts.clear();
|
||||
for (const auto &p : k.labels) {
|
||||
parts.push_back(std::hash<std::string>{}(p.first));
|
||||
parts.push_back(std::hash<std::string>{}(p.second));
|
||||
}
|
||||
return std::hash<std::string>{}(
|
||||
std::string{reinterpret_cast<const char *>(parts.data()),
|
||||
parts.size() * sizeof(size_t)});
|
||||
return std::hash<decltype(k.labels)>{}(k.labels);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@@ -142,6 +142,10 @@ Family<Histogram> create_histogram(std::string name, std::string help,
|
||||
std::initializer_list<double> buckets);
|
||||
|
||||
// Render all metrics in Prometheus text format
|
||||
// Returns chunks of Prometheus exposition format (includes # HELP and # TYPE
|
||||
// lines) Each string_view may contain multiple lines separated by '\n' String
|
||||
// views are NOT null-terminated - use .size() for length All string data
|
||||
// allocated in provided arena for zero-copy efficiency
|
||||
// TODO: Implement Prometheus text exposition format
|
||||
// THREAD SAFETY: Serialized by global mutex - callbacks need not be thread-safe
|
||||
std::span<std::string_view> render(ArenaAllocator &arena);
|
||||
|
||||
Reference in New Issue
Block a user