9 #define METRICS_STORE_ENTRY_PRIVATE
26 metrics_store_entry_t *
30 metrics_store_entry_t *entry = tor_malloc_zero(
sizeof(*entry));
35 entry->name = tor_strdup(
name);
38 entry->help = tor_strdup(help);
52 smartlist_free(entry->labels);
64 switch (entry->type) {
65 case METRICS_TYPE_COUNTER:
70 entry->u.counter.value += value;
72 case METRICS_TYPE_GAUGE:
74 entry->u.gauge.value += value;
85 memset(&entry->u, 0,
sizeof(entry->u));
94 switch (entry->type) {
95 case METRICS_TYPE_COUNTER:
96 if (entry->u.counter.value > INT64_MAX) {
99 return entry->u.counter.value;
100 case METRICS_TYPE_GAUGE:
101 return entry->u.gauge.value;
105 tor_assert_unreached();
Headers for util_malloc.c.
void metrics_store_entry_update(metrics_store_entry_t *entry, const int64_t value)
void metrics_store_entry_add_label(metrics_store_entry_t *entry, const char *label)
metrics_store_entry_t * metrics_store_entry_new(const metrics_type_t type, const char *name, const char *help)
void metrics_store_entry_free_(metrics_store_entry_t *entry)
int64_t metrics_store_entry_get_value(const metrics_store_entry_t *entry)
void metrics_store_entry_reset(metrics_store_entry_t *entry)
bool metrics_store_entry_has_label(const metrics_store_entry_t *entry, const char *label)
Header for lib/metrics/metrics_store_entry.c.
int smartlist_contains_string(const smartlist_t *sl, const char *element)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Macros to manage assertions, fatal and non-fatal.