diff --git a/src/metric.hpp b/src/metric.hpp index c00e300..3811653 100644 --- a/src/metric.hpp +++ b/src/metric.hpp @@ -123,10 +123,14 @@ template struct Family { static_assert(std::is_same_v || std::is_same_v || std::is_same_v); - // Create metric instance with specific labels - // Labels are sorted by key for Prometheus compatibility - // ERROR: Will abort if labels already registered via register_callback() - // OK: Multiple calls with same labels return same instance (idempotent) + // Create metric instance with specific labels. + // For performance, it is recommended to create instances once and cache them + // for reuse, rather than calling .create() repeatedly in + // performance-critical paths. + // + // Labels are sorted by key for Prometheus compatibility. + // ERROR: Will abort if labels already registered via register_callback(). + // OK: Multiple calls with same labels return same instance (idempotent). T create(std::initializer_list> labels) { return create(