Lines Matching +full:zephyr +full:- +full:base

5  * SPDX-License-Identifier: Apache-2.0
8 #include <zephyr/net/prometheus/collector.h>
10 #include <zephyr/net/prometheus/metric.h>
11 #include <zephyr/net/prometheus/histogram.h>
12 #include <zephyr/net/prometheus/summary.h>
13 #include <zephyr/net/prometheus/counter.h>
14 #include <zephyr/net/prometheus/gauge.h>
15 #include <zephyr/net/prometheus/formatter.h>
20 #include <zephyr/kernel.h>
21 #include <zephyr/sys/iterable_sections.h>
23 #include <zephyr/logging/log.h>
31 return -EINVAL; in prometheus_collector_register_metric()
34 LOG_DBG("Registering metric type=%d name=\"%s\"", metric->type, metric->name); in prometheus_collector_register_metric()
36 k_mutex_lock(&collector->lock, K_FOREVER); in prometheus_collector_register_metric()
39 (void)sys_slist_find_and_remove(&collector->metrics, &metric->node); in prometheus_collector_register_metric()
41 sys_slist_prepend(&collector->metrics, &metric->node); in prometheus_collector_register_metric()
43 k_mutex_unlock(&collector->lock); in prometheus_collector_register_metric()
51 LOG_DBG("entry->name: %s", entry->base.name); in prometheus_get_counter_metric()
53 if (strncmp(entry->base.name, name, strlen(entry->base.name)) == 0) { in prometheus_get_counter_metric()
54 LOG_DBG("Counter found %s", entry->base.name); in prometheus_get_counter_metric()
67 LOG_DBG("entry->name: %s", entry->base.name); in prometheus_get_gauge_metric()
69 if (strncmp(entry->base.name, name, strlen(entry->base.name)) == 0) { in prometheus_get_gauge_metric()
70 LOG_DBG("Counter found %s", entry->base.name); in prometheus_get_gauge_metric()
83 LOG_DBG("entry->name: %s", entry->base.name); in prometheus_get_histogram_metric()
85 if (strncmp(entry->base.name, name, strlen(entry->base.name)) == 0) { in prometheus_get_histogram_metric()
86 LOG_DBG("Counter found %s", entry->base.name); in prometheus_get_histogram_metric()
99 LOG_DBG("entry->name: %s", entry->base.name); in prometheus_get_summary_metric()
101 if (strncmp(entry->base.name, name, strlen(entry->base.name)) == 0) { in prometheus_get_summary_metric()
102 LOG_DBG("Counter found %s", entry->base.name); in prometheus_get_summary_metric()
124 k_mutex_lock(&collector->lock, K_FOREVER); in prometheus_collector_get_metric()
126 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&collector->metrics, metric, tmp, node) { in prometheus_collector_get_metric()
128 if (strncmp(metric->name, name, strlen(metric->name)) == 0) { in prometheus_collector_get_metric()
129 type = metric->type; in prometheus_collector_get_metric()
132 LOG_DBG("metric found: %s", metric->name); in prometheus_collector_get_metric()
137 k_mutex_unlock(&collector->lock); in prometheus_collector_get_metric()
146 return CONTAINER_OF(metric, struct prometheus_counter, base); in prometheus_collector_get_metric()
148 return CONTAINER_OF(metric, struct prometheus_gauge, base); in prometheus_collector_get_metric()
150 return CONTAINER_OF(metric, struct prometheus_histogram, base); in prometheus_collector_get_metric()
152 return CONTAINER_OF(metric, struct prometheus_summary, base); in prometheus_collector_get_metric()
167 if (ctx->collector == NULL) { in prometheus_collector_walk_metrics()
169 return -EINVAL; in prometheus_collector_walk_metrics()
172 if (ctx->state == PROMETHEUS_WALK_START) { in prometheus_collector_walk_metrics()
173 k_mutex_lock(&ctx->collector->lock, K_FOREVER); in prometheus_collector_walk_metrics()
174 ctx->state = PROMETHEUS_WALK_CONTINUE; in prometheus_collector_walk_metrics()
181 ctx->metric = Z_GENLIST_PEEK_HEAD_CONTAINER(slist, in prometheus_collector_walk_metrics()
182 &ctx->collector->metrics, in prometheus_collector_walk_metrics()
183 ctx->metric, in prometheus_collector_walk_metrics()
185 ctx->tmp = Z_GENLIST_PEEK_NEXT_CONTAINER(slist, in prometheus_collector_walk_metrics()
186 ctx->metric, in prometheus_collector_walk_metrics()
190 if (ctx->state == PROMETHEUS_WALK_CONTINUE) { in prometheus_collector_walk_metrics()
193 ctx->metric = ctx->tmp; in prometheus_collector_walk_metrics()
194 ctx->tmp = Z_GENLIST_PEEK_NEXT_CONTAINER(slist, in prometheus_collector_walk_metrics()
195 ctx->metric, in prometheus_collector_walk_metrics()
198 if (ctx->metric == NULL) { in prometheus_collector_walk_metrics()
199 ctx->state = PROMETHEUS_WALK_STOP; in prometheus_collector_walk_metrics()
204 if (ctx->collector->user_cb) { in prometheus_collector_walk_metrics()
205 ret = ctx->collector->user_cb(ctx->collector, ctx->metric, in prometheus_collector_walk_metrics()
206 ctx->collector->user_data); in prometheus_collector_walk_metrics()
208 if (ret != -EAGAIN) { in prometheus_collector_walk_metrics()
209 ctx->state = PROMETHEUS_WALK_STOP; in prometheus_collector_walk_metrics()
218 ret = prometheus_format_one_metric(ctx->metric, buffer, buffer_size, &len); in prometheus_collector_walk_metrics()
220 ctx->state = PROMETHEUS_WALK_STOP; in prometheus_collector_walk_metrics()
224 ret = -EAGAIN; in prometheus_collector_walk_metrics()
228 if (ctx->state == PROMETHEUS_WALK_STOP) { in prometheus_collector_walk_metrics()
229 k_mutex_unlock(&ctx->collector->lock); in prometheus_collector_walk_metrics()