aboutsummaryrefslogtreecommitdiff
path: root/src/lib/metrics/metrics_store_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/metrics/metrics_store_entry.c')
-rw-r--r--src/lib/metrics/metrics_store_entry.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/metrics/metrics_store_entry.c b/src/lib/metrics/metrics_store_entry.c
index 482ec8d7d9..971d9379bd 100644
--- a/src/lib/metrics/metrics_store_entry.c
+++ b/src/lib/metrics/metrics_store_entry.c
@@ -127,3 +127,23 @@ metrics_store_entry_has_label(const metrics_store_entry_t *entry,
return smartlist_contains_string(entry->labels, label);
}
+
+/** Return the first entry that has the given label, or NULL if none
+ * of the entries have the label. */
+metrics_store_entry_t *
+metrics_store_find_entry_with_label(const smartlist_t *entries,
+ const char *label)
+{
+ tor_assert(entries);
+ tor_assert(label);
+
+ SMARTLIST_FOREACH_BEGIN(entries, metrics_store_entry_t *, entry) {
+ tor_assert(entry);
+
+ if (smartlist_contains_string(entry->labels, label)) {
+ return entry;
+ }
+ } SMARTLIST_FOREACH_END(entry);
+
+ return NULL;
+}