Tor  0.4.7.0-alpha-dev
metrics_common.h
Go to the documentation of this file.
1 /* Copyright (c) 2020-2021, 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 /* Helpers. */
46 const char *metrics_format_label(const char *key, const char *value);
47 
48 #endif /* !defined(TOR_LIB_METRICS_METRICS_COMMON_H) */
metrics_type_t
const char * metrics_format_label(const char *key, const char *value)
const char * metrics_type_to_str(const metrics_type_t type)
metrics_format_t
@ METRICS_FORMAT_PROMETHEUS
Integer definitions used throughout Tor.