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>
30 lines
512 B
C
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;
|
|
}
|