zephyr/subsys/net/lib/prometheus/summary.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

31 lines
541 B
C

/*
* Copyright (c) 2024 Mustafa Abdullah Kus, Sparse Technology
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/net/prometheus/summary.h>
#include <stdlib.h>
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(pm_summary, CONFIG_PROMETHEUS_LOG_LEVEL);
int prometheus_summary_observe(struct prometheus_summary *summary, double value)
{
if (!summary) {
return -EINVAL;
}
/* increment count */
summary->count++;
/* update sum */
summary->sum += value;
return 0;
}