diff --git a/src/metric.cpp b/src/metric.cpp index f58645e..26451e9 100644 --- a/src/metric.cpp +++ b/src/metric.cpp @@ -76,15 +76,7 @@ struct LabelsKey { namespace std { template <> struct hash { std::size_t operator()(const metric::LabelsKey &k) const { - thread_local std::vector parts; - parts.clear(); - for (const auto &p : k.labels) { - parts.push_back(std::hash{}(p.first)); - parts.push_back(std::hash{}(p.second)); - } - return std::hash{}( - std::string{reinterpret_cast(parts.data()), - parts.size() * sizeof(size_t)}); + return std::hash{}(k.labels); } }; } // namespace std diff --git a/src/metric.hpp b/src/metric.hpp index 3ccdb8e..4113065 100644 --- a/src/metric.hpp +++ b/src/metric.hpp @@ -142,6 +142,10 @@ Family create_histogram(std::string name, std::string help, std::initializer_list 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 render(ArenaAllocator &arena);