metrics_common.h 1.13 KB
Newer Older
David Goulet's avatar
David Goulet committed
1
2
3
4
5
6
7
8
9
10
11
12
13
/* Copyright (c) 2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * @file metrics_common.h
 * @brief Header for lib/metrics/metrics_common.c
 **/

#ifndef TOR_LIB_METRICS_METRICS_COMMON_H
#define TOR_LIB_METRICS_METRICS_COMMON_H

#include "lib/cc/torint.h"

14
15
16
/** Helper macro that must be used to construct the right namespaced metrics
 * name. A name is a string so stringify the result. */
#define METRICS_STR(val) #val
17
#define METRICS_NAME(name) METRICS_STR(tor_ ## name)
18

David Goulet's avatar
David Goulet committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/** Format output type. */
typedef enum {
  /** Prometheus data output format. */
  METRICS_FORMAT_PROMETHEUS = 1,
} metrics_format_t;

/** Metric type. */
typedef enum {
  /* Increment only. */
  METRICS_TYPE_COUNTER,
  /* Can go up or down. */
  METRICS_TYPE_GAUGE,
} metrics_type_t;

/** Metric counter object (METRICS_TYPE_COUNTER). */
typedef struct metrics_counter_t {
  uint64_t value;
} metrics_counter_t;

/** Metric gauge object (METRICS_TYPE_GAUGE). */
typedef struct metrics_gauge_t {
  int64_t value;
} metrics_gauge_t;

const char *metrics_type_to_str(const metrics_type_t type);

#endif /* !defined(TOR_LIB_METRICS_METRICS_COMMON_H) */