Zephyr API Documentation 4.0.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
24
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
83
90static inline int prometheus_counter_inc(struct prometheus_counter *counter)
91{
92 return prometheus_counter_add(counter, 1ULL);
93}
94
106
111#endif /* ZEPHYR_INCLUDE_PROMETHEUS_COUNTER_H_ */
int prometheus_counter_set(struct prometheus_counter *counter, uint64_t value)
Set the counter value to specific value.
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...
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
Prometheus metric interface.
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Type used to represent a Prometheus counter metric.
Definition counter.h:31
uint64_t value
Value of the Prometheus counter metric.
Definition counter.h:35
void * user_data
User data.
Definition counter.h:37
struct prometheus_metric base
Base of the Prometheus counter metric.
Definition counter.h:33
Type used to represent a Prometheus metric base.
Definition metric.h:47