Error handling on system boot (#30)

Implements #3

Reviewed-on: #30
Co-authored-by: localhorst <localhorst@mosad.xyz>
Co-committed-by: localhorst <localhorst@mosad.xyz>
This commit was merged in pull request #30.
This commit is contained in:
2026-05-10 12:39:47 +02:00
committed by Hendrik Schutter
parent 085f5b4acb
commit a7d577a948
16 changed files with 930 additions and 399 deletions
+46 -11
View File
@@ -1,26 +1,61 @@
/**
* @file metrics.h
* @brief Prometheus metrics HTTP endpoint.
*
* This module provides a HTTP server on port 9100 that exposes
* system metrics in Prometheus format at /metrics endpoint.
*/
#pragma once
#include <esp_http_server.h>
#include "esp_err.h"
#include "esp_http_server.h"
#include <stdint.h>
/** @brief Maximum size of HTTP response buffer. */
#define HTML_RESPONSE_SIZE 4096U
/** @brief Maximum length of metric name. */
#define METRIC_NAME_MAX_SIZE 64U
/** @brief Maximum number of metrics. */
#define METRIC_MAX_COUNT 38U
/**
* @brief Metric value type enumeration.
*/
typedef enum _MetricValueType
{
FLOAT,
INTEGER_U8,
INTEGER_64,
FLOAT, /**< Floating point value. */
INTEGER_U8, /**< 8-bit unsigned integer. */
INTEGER_64, /**< 64-bit signed integer. */
} eMetricValueType;
/**
* @brief Metric data structure.
*/
typedef struct _metric
{
char caMetricName[METRIC_NAME_MAX_SIZE];
eMetricValueType type;
float fMetricValue;
uint8_t u8MetricValue;
int64_t i64MetricValue;
char caMetricName[METRIC_NAME_MAX_SIZE]; /**< Metric name. */
eMetricValueType type; /**< Value type. */
float fMetricValue; /**< Float value (if type is FLOAT). */
uint8_t u8MetricValue; /**< U8 value (if type is INTEGER_U8). */
int64_t i64MetricValue; /**< I64 value (if type is INTEGER_64). */
} sMetric;
void initMetrics(void);
void vSetMetrics(sMetric *paMetrics, uint16_t u16Size);
/**
* @brief Initialize the metrics module.
*
* Starts the HTTP server and creates the metrics collection task.
*
* @return ESP_OK on success, ESP_FAIL on error.
*/
esp_err_t initMetrics(void);
/**
* @brief Update the metrics buffer.
* @param paMetrics Array of metrics to publish.
* @param u16Size Number of metrics in array.
*/
void vSetMetrics(sMetric *paMetrics, uint16_t u16Size);