Make recording metrics never block

This commit is contained in:
2025-09-15 23:34:30 -04:00
parent 0659319906
commit 4d015fa3dc
2 changed files with 67 additions and 43 deletions

View File

@@ -73,7 +73,7 @@ template <typename T> using MetricCallback = std::function<double()>;
// 3. When rendered, the values of all Counter objects with the same labels
// are summed together into a single total.
struct Counter {
void inc(double = 1.0); // Increment counter (must be >= 0)
void inc(double = 1.0); // Increment counter (must be >= 0, never blocks)
private:
Counter();
@@ -94,9 +94,9 @@ private:
// are cumulative.
// 4. For independent gauges, create them with unique labels.
struct Gauge {
void inc(double = 1.0);
void dec(double = 1.0);
void set(double);
void inc(double = 1.0); // (never blocks)
void dec(double = 1.0); // (never blocks)
void set(double); // (never blocks)
private:
Gauge();
@@ -116,7 +116,8 @@ private:
// 3. When rendered, the observations from all Histogram objects with the
// same labels are combined into a single histogram.
struct Histogram {
void observe(double); // Record observation in appropriate bucket
void
observe(double); // Record observation in appropriate bucket (never blocks)
private:
Histogram();