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

@@ -20,6 +20,14 @@
// typical Prometheus client libraries that support multiple registries.
// This design choice prioritizes simplicity and performance over flexibility.
//
// PERFORMANCE NOTE:
// Family registration operations (create_counter/gauge/histogram), metric
// instance creation (.create()), and render() use a global mutex for thread
// safety. Registration operations should be performed during application
// initialization, not in performance-critical paths. Metric update operations
// (inc/dec/set/observe) are designed for high-frequency use and do not contend
// on the global mutex.
//
// METRIC LIFECYCLE:
// Metrics are created once and persist for the application lifetime. There is
// no unregistration mechanism - this prevents accidental metric loss and