1 /*
2  * Copyright (c) 2024 Mustafa Abdullah Kus, Sparse Technology
3  * Copyright (c) 2024 Nordic Semiconductor
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_
9 #define ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_
10 
11 /**
12  * @file
13  *
14  * @brief Prometheus metric interface.
15  *
16  * @addtogroup prometheus
17  * @{
18  */
19 
20 #include <zephyr/sys/iterable_sections.h>
21 #include <zephyr/sys/slist.h>
22 #include <zephyr/net/prometheus/label.h>
23 
24 /**
25  * @brief Prometheus metric types.
26  *
27  * * References
28  * * See https://prometheus.io/docs/concepts/metric_types
29  */
30 enum prometheus_metric_type {
31 	/** Prometheus Counter */
32 	PROMETHEUS_COUNTER = 0,
33 	/** Prometheus Gauge */
34 	PROMETHEUS_GAUGE,
35 	/** Prometheus Summary */
36 	PROMETHEUS_SUMMARY,
37 	/** Prometheus Histogram */
38 	PROMETHEUS_HISTOGRAM,
39 };
40 
41 /**
42  * @brief Type used to represent a Prometheus metric base.
43  *
44  * Every metric has a prometheus_metric structure associated used
45  * to control the metric access and usage.
46  */
47 struct prometheus_metric {
48 	/** Slist metric list node */
49 	sys_snode_t node;
50 	/** Back pointer to the collector that this metric belongs to */
51 	struct prometheus_collector *collector;
52 	/** Back pointer to the actual metric (counter, gauge, etc.).
53 	 * This is just a temporary solution, ultimate goal is to place
54 	 * this generic metrict struct into the actual metric struct.
55 	 */
56 	void *metric;
57 	/** Type of the Prometheus metric. */
58 	enum prometheus_metric_type type;
59 	/** Name of the Prometheus metric. */
60 	const char *name;
61 	/** Description of the Prometheus metric. */
62 	const char *description;
63 	/** Labels associated with the Prometheus metric. */
64 	struct prometheus_label labels[MAX_PROMETHEUS_LABELS_PER_METRIC];
65 	/** Number of labels associated with the Prometheus metric. */
66 	int num_labels;
67 	/** User defined data */
68 	void *user_data;
69 	/* Add any other necessary fields */
70 };
71 
72 /**
73  * @}
74  */
75 
76 #endif /* ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_ */
77