Zephyr API Documentation
4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
counter.h
Go to the documentation of this file.
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_COUNTER_H_
9
#define ZEPHYR_INCLUDE_PROMETHEUS_COUNTER_H_
10
20
#include <
stdint.h
>
21
22
#include <
zephyr/sys/iterable_sections.h
>
23
#include <
zephyr/net/prometheus/metric.h
>
24
31
struct
prometheus_counter
{
33
struct
prometheus_metric
base
;
35
uint64_t
value
;
37
void
*
user_data
;
38
};
39
60
#define PROMETHEUS_COUNTER_DEFINE(_name, _desc, _label, _collector, ...) \
61
STRUCT_SECTION_ITERABLE(prometheus_counter, _name) = { \
62
.base.name = STRINGIFY(_name), \
63
.base.type = PROMETHEUS_COUNTER, \
64
.base.description = _desc, \
65
.base.labels[0] = __DEBRACKET _label, \
66
.base.num_labels = 1, \
67
.base.collector = _collector, \
68
.value = 0ULL, \
69
.user_data = COND_CODE_0( \
70
NUM_VA_ARGS_LESS_1(LIST_DROP_EMPTY(__VA_ARGS__, _)), \
71
(NULL), \
72
(GET_ARG_N(1, __VA_ARGS__))), \
73
}
74
82
int
prometheus_counter_add
(
struct
prometheus_counter
*
counter
,
uint64_t
value);
83
90
static
inline
int
prometheus_counter_inc
(
struct
prometheus_counter
*
counter
)
91
{
92
return
prometheus_counter_add
(
counter
, 1ULL);
93
}
94
105
int
prometheus_counter_set
(
struct
prometheus_counter
*
counter
,
uint64_t
value);
106
111
#endif
/* ZEPHYR_INCLUDE_PROMETHEUS_COUNTER_H_ */
prometheus_counter_set
int prometheus_counter_set(struct prometheus_counter *counter, uint64_t value)
Set the counter value to specific value.
prometheus_counter_add
int prometheus_counter_add(struct prometheus_counter *counter, uint64_t value)
Increment the value of a Prometheus counter metric Increments the value of the specified counter metr...
prometheus_counter_inc
static int prometheus_counter_inc(struct prometheus_counter *counter)
Increment the value of a Prometheus counter metric Increments the value of the specified counter metr...
Definition
counter.h:90
counter
static int __noinit counter
Definition
main.c:88
metric.h
Prometheus metric interface.
stdint.h
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:91
prometheus_counter
Type used to represent a Prometheus counter metric.
Definition
counter.h:31
prometheus_counter::value
uint64_t value
Value of the Prometheus counter metric.
Definition
counter.h:35
prometheus_counter::user_data
void * user_data
User data.
Definition
counter.h:37
prometheus_counter::base
struct prometheus_metric base
Base of the Prometheus counter metric.
Definition
counter.h:33
prometheus_metric
Type used to represent a Prometheus metric base.
Definition
metric.h:47
iterable_sections.h
zephyr
net
prometheus
counter.h
Generated on Mon Apr 21 2025 11:55:48 for Zephyr API Documentation by
1.12.0