Make metrics thread-safe
Some checks failed
Tests / Clang total: 1533, failed: 1, passed: 1532
Tests / Clang - debug total: 1531, passed: 1531
Tests / SIMD fallback total: 1533, failed: 1, passed: 1532
Tests / Release [gcc] total: 1533, failed: 1, passed: 1532
Tests / Release [gcc,aarch64] total: 1144, failed: 2, passed: 1142
Tests / Coverage total: 1151, passed: 1151
weaselab/conflict-set/pipeline/head There was a failure building this commit

Even concurrently with calling non-const methods on the associated
ConflictSet
This commit is contained in:
2024-07-12 13:22:02 -07:00
parent ef14003781
commit 3288c583e4
10 changed files with 111 additions and 22 deletions

View File

@@ -101,9 +101,10 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
const char *help;
/** Counters are >= 0 and non-decreasing. Gauges are any value. */
enum Type { Counter, Gauge } type;
/** Thread-safety: do not read concurrently with a call to any non-const
* method in the ConflictSet associated with this metric. */
const double *value;
/** Get the most up-to-date value available for this metric. Thread-safe. */
double getValue() const;
/** @private */
void *p;
};
/** Experimental! Store a pointer to an array of MetricsV1 (owned by the
@@ -111,7 +112,8 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
* no guarantees about the contents of the metrics (e.g. names, help text, and
* the meaning of values). A correct implementation is free to return nonsense
* or nothing at all. Not intended to be inspected programmatically. Only
* intended to be plumbed along to e.g. Prometheus. */
* intended to be plumbed along to e.g. Prometheus. Callers may repeatedly
* call `getValue` on the metrics they're interested in. */
void getMetricsV1(MetricsV1 **metrics, int *count) const;
#if __cplusplus > 199711L