LCOV - code coverage report
Current view: top level - zephyr/net/prometheus - metric.h Hit Total Coverage
Test: new.info Lines: 8 10 80.0 %
Date: 2024-10-22 03:18:24

          Line data    Source code
       1           1 : /*
       2             :  * Copyright (c) 2024 Mustafa Abdullah Kus, Sparse Technology
       3             :  *
       4             :  * SPDX-License-Identifier: Apache-2.0
       5             :  */
       6             : 
       7             : #ifndef ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_
       8             : #define ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_
       9             : 
      10             : /**
      11             :  * @file
      12             :  *
      13             :  * @brief Prometheus metric interface.
      14             :  *
      15             :  * @addtogroup prometheus
      16             :  * @{
      17             :  */
      18             : 
      19             : #include <zephyr/sys/iterable_sections.h>
      20             : #include <zephyr/net/prometheus/label.h>
      21             : 
      22             : /**
      23             :  * @brief Prometheus metric types.
      24             :  *
      25             :  * * References
      26             :  * * See https://prometheus.io/docs/concepts/metric_types
      27             :  */
      28           1 : enum prometheus_metric_type {
      29             :         /** Prometheus Counter */
      30             :         PROMETHEUS_COUNTER = 0,
      31             :         /** Prometheus Gauge */
      32             :         PROMETHEUS_GAUGE,
      33             :         /** Prometheus Summary */
      34             :         PROMETHEUS_SUMMARY,
      35             :         /** Prometheus Histogram */
      36             :         PROMETHEUS_HISTOGRAM,
      37             : };
      38             : 
      39           0 : #define MAX_METRIC_NAME_LENGTH        32
      40           0 : #define MAX_METRIC_DESCRIPTION_LENGTH 64
      41             : 
      42             : /**
      43             :  * @brief Type used to represent a Prometheus metric base.
      44             :  *
      45             :  * Every metric has a prometheus_metric structure associated used
      46             :  * to control the metric access and usage.
      47             :  */
      48           1 : struct prometheus_metric {
      49             :         /** Type of the Prometheus metric. */
      50           1 :         enum prometheus_metric_type type;
      51             :         /** Name of the Prometheus metric. */
      52           1 :         char name[MAX_METRIC_NAME_LENGTH];
      53             :         /** Description of the Prometheus metric. */
      54           1 :         char description[MAX_METRIC_DESCRIPTION_LENGTH];
      55             :         /** Labels associated with the Prometheus metric. */
      56           1 :         struct prometheus_label labels[MAX_PROMETHEUS_LABELS_PER_METRIC];
      57             :         /** Number of labels associated with the Prometheus metric. */
      58           1 :         int num_labels;
      59             :         /* Add any other necessary fields */
      60             : };
      61             : 
      62             : /**
      63             :  * @}
      64             :  */
      65             : 
      66             : #endif /* ZEPHYR_INCLUDE_PROMETHEUS_METRIC_H_ */

Generated by: LCOV version 1.14