net: prometheus: Add more parameters to metric macros
Add collector parameter to metric creation macros so that it is possible to bind the metric to collector already at built time. Also add optional user_data to metric macro calls so that user can add optional data there. This will be used by network statistics Prometheus support in subsequent commits. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
fdae68ac5d
commit
c7989b5747
13 changed files with 117 additions and 17 deletions
|
@ -10,7 +10,7 @@
|
|||
#include <zephyr/net/prometheus/collector.h>
|
||||
|
||||
PROMETHEUS_COUNTER_DEFINE(test_counter_m, "Test counter",
|
||||
({ .key = "test_counter", .value = "test" }));
|
||||
({ .key = "test_counter", .value = "test" }), NULL);
|
||||
|
||||
PROMETHEUS_COLLECTOR_DEFINE(test_custom_collector);
|
||||
|
||||
|
@ -31,9 +31,11 @@ ZTEST(test_collector, test_prometheus_collector_register)
|
|||
prometheus_collector_register_metric(&test_custom_collector, &test_counter_m.base);
|
||||
|
||||
counter = (struct prometheus_counter *)prometheus_collector_get_metric(
|
||||
&test_custom_collector, "test_counter");
|
||||
&test_custom_collector, "test_counter_m");
|
||||
|
||||
zassert_equal(counter, &test_counter_m, "Counter not found in collector");
|
||||
zassert_equal_ptr(counter, &test_counter_m,
|
||||
"Counter not found in collector (expected %p, got %p)",
|
||||
&test_counter_m, counter);
|
||||
|
||||
zassert_equal(test_counter_m.value, 0, "Counter value is not 0");
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include <zephyr/net/prometheus/counter.h>
|
||||
|
||||
PROMETHEUS_COUNTER_DEFINE(test_counter_m, "Test counter",
|
||||
({ .key = "test_counter", .value = "test" }));
|
||||
({ .key = "test_counter", .value = "test" }),
|
||||
NULL);
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_counter_inc
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <zephyr/net/prometheus/gauge.h>
|
||||
|
||||
PROMETHEUS_GAUGE_DEFINE(test_gauge_m, "Test gauge",
|
||||
({ .key = "test", .value = "gauge" }));
|
||||
({ .key = "test", .value = "gauge" }), NULL);
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_gauge_set
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <zephyr/net/prometheus/histogram.h>
|
||||
|
||||
PROMETHEUS_HISTOGRAM_DEFINE(test_histogram_m, "Test histogram",
|
||||
({ .key = "test", .value = "histogram" }));
|
||||
({ .key = "test", .value = "histogram" }), NULL);
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_histogram_observe
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <zephyr/net/prometheus/summary.h>
|
||||
|
||||
PROMETHEUS_SUMMARY_DEFINE(test_summary_m, "Test summary",
|
||||
({ .key = "test", .value = "summary" }));
|
||||
({ .key = "test", .value = "summary" }), NULL);
|
||||
|
||||
/**
|
||||
* @brief Test prometheus_summary_observe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue