Add performance note to header

Also improve implementation comments
This commit is contained in:
2025-09-03 11:18:03 -04:00
parent 17efcf318e
commit 13e4039ed6
2 changed files with 10 additions and 4 deletions

View File

@@ -1405,8 +1405,7 @@ Family<Gauge> create_gauge(std::string_view name, std::string_view help) {
auto name_view = arena_copy_string(name, global_arena);
auto &familyPtr = Metric::get_gauge_families()[name_view];
if (!familyPtr) {
// NOTE: Family<T>::State instances are never destroyed - this is fine
// because the number of metric families is bounded by application design
// Family<T>::State instances use ArenaAllocator::Ptr for automatic cleanup
familyPtr = global_arena.construct<Family<Gauge>::State>(global_arena);
familyPtr->name = name_view;
familyPtr->help = arena_copy_string(help, global_arena);
@@ -1430,8 +1429,7 @@ Family<Histogram> create_histogram(std::string_view name, std::string_view help,
auto name_view = arena_copy_string(name, global_arena);
auto &family_ptr = Metric::get_histogram_families()[name_view];
if (!family_ptr) {
// NOTE: Family<T>::State instances are never destroyed - this is fine
// because the number of metric families is bounded by application design
// Family<T>::State instances use ArenaAllocator::Ptr for automatic cleanup
family_ptr = global_arena.construct<Family<Histogram>::State>(global_arena);
family_ptr->name = name_view;
family_ptr->help = arena_copy_string(help, global_arena);