LCOV - code coverage report
Current view: top level - disco/metrics - fd_metrics_base.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 1 14 7.1 %
Date: 2024-11-13 11:58:15 Functions: 0 80 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_metrics_fd_metrics_base_h
       2             : #define HEADER_fd_src_disco_metrics_fd_metrics_base_h
       3             : 
       4             : #include "../../util/fd_util.h"
       5             : 
       6           0 : #define FD_METRICS_TYPE_GAUGE     (0UL)
       7           0 : #define FD_METRICS_TYPE_COUNTER   (1UL)
       8           0 : #define FD_METRICS_TYPE_HISTOGRAM (2UL)
       9             : 
      10           0 : #define FD_METRICS_CONVERTER_NONE        (0UL)
      11             : #define FD_METRICS_CONVERTER_SECONDS     (1UL)
      12           0 : #define FD_METRICS_CONVERTER_NANOSECONDS (2UL)
      13             : 
      14     6790137 : #define MIDX( type, group, measurement ) (FD_METRICS_##type##_##group##_##measurement##_OFF)
      15             : 
      16             : #define DECLARE_METRIC_GAUGE( GROUP, MEASUREMENT ) {              \
      17             :     .name      = FD_METRICS_GAUGE_##GROUP##_##MEASUREMENT##_NAME, \
      18             :     .type      = FD_METRICS_TYPE_GAUGE,                           \
      19             :     .desc      = FD_METRICS_GAUGE_##GROUP##_##MEASUREMENT##_DESC, \
      20             :     .offset    = FD_METRICS_GAUGE_##GROUP##_##MEASUREMENT##_OFF,  \
      21             :     .converter = FD_METRICS_GAUGE_##GROUP##_##MEASUREMENT##_CVT   \
      22             :   }
      23             : 
      24             : #define DECLARE_METRIC_COUNTER( GROUP, MEASUREMENT ) {              \
      25             :     .name      = FD_METRICS_COUNTER_##GROUP##_##MEASUREMENT##_NAME, \
      26             :     .type      = FD_METRICS_TYPE_COUNTER,                           \
      27             :     .desc      = FD_METRICS_COUNTER_##GROUP##_##MEASUREMENT##_DESC, \
      28             :     .offset    = FD_METRICS_COUNTER_##GROUP##_##MEASUREMENT##_OFF,  \
      29             :     .converter = FD_METRICS_COUNTER_##GROUP##_##MEASUREMENT##_CVT   \
      30             :   }
      31             : 
      32             : #define DECLARE_METRIC_HISTOGRAM_NONE( GROUP, MEASUREMENT ) {        \
      33             :     .name = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_NAME,     \
      34             :     .type = FD_METRICS_TYPE_HISTOGRAM,                               \
      35             :     .desc = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_DESC,     \
      36             :     .offset = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_OFF,    \
      37             :     .converter = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_CVT, \
      38             :     .histogram = {                                                   \
      39             :       .none = {                                                      \
      40             :         .min = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_MIN,   \
      41             :         .max = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_MAX,   \
      42             :       },                                                             \
      43             :     },                                                               \
      44             :   }
      45             : 
      46             : #define DECLARE_METRIC_HISTOGRAM_SECONDS( GROUP, MEASUREMENT ) {     \
      47             :     .name = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_NAME,     \
      48             :     .type = FD_METRICS_TYPE_HISTOGRAM,                               \
      49             :     .desc = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_DESC,     \
      50             :     .offset = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_OFF,    \
      51             :     .converter = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_CVT, \
      52             :     .histogram = {                                                   \
      53             :       .seconds = {                                                   \
      54             :         .min = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_MIN,   \
      55             :         .max = FD_METRICS_HISTOGRAM_##GROUP##_##MEASUREMENT##_MAX,   \
      56             :       },                                                             \
      57             :     },                                                               \
      58             :   }
      59             : 
      60             : typedef struct {
      61             :   char const * name;
      62             :   int          type;
      63             :   char const * desc;
      64             :   ulong        offset;
      65             : 
      66             :   int converter;
      67             : 
      68             :   union {
      69             :     struct {
      70             : 
      71             :       union {
      72             :         struct {
      73             :           ulong min;
      74             :           ulong max;
      75             :         } none;
      76             :         
      77             :         struct {
      78             :           double min;
      79             :           double max;
      80             :         } seconds;
      81             :       };
      82             :     } histogram;
      83             :   };
      84             : } fd_metrics_meta_t;
      85             : 
      86             : FD_PROTOTYPES_BEGIN
      87             : 
      88             : FD_FN_PURE static inline char *
      89           0 : fd_metrics_meta_type_str( fd_metrics_meta_t const * metric ) {
      90           0 :   switch( metric->type ) {
      91           0 :     case FD_METRICS_TYPE_GAUGE:     return "gauge";
      92           0 :     case FD_METRICS_TYPE_COUNTER:   return "counter";
      93           0 :     case FD_METRICS_TYPE_HISTOGRAM: return "histogram";
      94           0 :     default:                        return "unknown";
      95           0 :   }
      96           0 : }
      97             : 
      98             : FD_PROTOTYPES_END
      99             : 
     100             : #endif /* HEADER_fd_src_disco_metrics_fd_metrics_base_h */

Generated by: LCOV version 1.14