Tor  0.4.6.0-alpha-dev
metrics_common.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * @file metrics_common.h
6  * @brief Header for lib/metrics/metrics_common.c
7  **/
8 
9 #ifndef TOR_LIB_METRICS_METRICS_COMMON_H
10 #define TOR_LIB_METRICS_METRICS_COMMON_H
11 
12 #include "lib/cc/torint.h"
13 
14 /** Helper macro that must be used to construct the right namespaced metrics
15  * name. A name is a string so stringify the result. */
16 #define METRICS_STR(val) #val
17 #define METRICS_NAME(name) METRICS_STR(tor_ ## name)
18 
19 /** Format output type. */
20 typedef enum {
21  /** Prometheus data output format. */
24 
25 /** Metric type. */
26 typedef enum {
27  /* Increment only. */
28  METRICS_TYPE_COUNTER,
29  /* Can go up or down. */
30  METRICS_TYPE_GAUGE,
32 
33 /** Metric counter object (METRICS_TYPE_COUNTER). */
34 typedef struct metrics_counter_t {
35  uint64_t value;
37 
38 /** Metric gauge object (METRICS_TYPE_GAUGE). */
39 typedef struct metrics_gauge_t {
40  int64_t value;
42 
43 const char *metrics_type_to_str(const metrics_type_t type);
44 
45 #endif /* !defined(TOR_LIB_METRICS_METRICS_COMMON_H) */
torint.h
Integer definitions used throughout Tor.
metrics_counter_t
Definition: metrics_common.h:34
METRICS_FORMAT_PROMETHEUS
@ METRICS_FORMAT_PROMETHEUS
Definition: metrics_common.h:22
metrics_type_t
metrics_type_t
Definition: metrics_common.h:26
metrics_type_to_str
const char * metrics_type_to_str(const metrics_type_t type)
Definition: metrics_common.c:19
metrics_gauge_t
Definition: metrics_common.h:39
metrics_format_t
metrics_format_t
Definition: metrics_common.h:20