zephyr/subsys/net/lib/prometheus/gauge.c
Mustafa Abdullah Kus d482e3ddfc net: add initial prometheus client library
The library provides Prometheus metrics
types, collector and exposion formatter.
The library isn't thread-safe for now.
The next first pull request will support
that. Can be use exposion formatted
output with Zephyr Http server.

Signed-off-by: Mustafa Abdullah Kus <mustafa.kus@sparsetechnology.com>
2024-10-18 14:17:11 +02:00

30 lines
512 B
C

/*
* Copyright (c) 2024 Mustafa Abdullah Kus, Sparse Technology
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/net/prometheus/gauge.h>
#include <stdlib.h>
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(pm_gauge, CONFIG_PROMETHEUS_LOG_LEVEL);
int prometheus_gauge_set(struct prometheus_gauge *gauge, double value)
{
if (value < 0) {
LOG_ERR("Invalid value");
return -EINVAL;
}
if (gauge) {
gauge->value = value;
}
return 0;
}