1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* Copyright (c) 2020-2021, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* @file hs_metrics_entry.c
* @brief Defines the metrics entry that are collected by an onion service.
**/
#define HS_METRICS_ENTRY_PRIVATE
#include <stddef.h>
#include "orconfig.h"
#include "lib/cc/compat_compiler.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "feature/hs/hs_metrics_entry.h"
/* Histogram time buckets (in milliseconds). */
static const int64_t hs_metrics_circ_build_time_buckets[] =
{
1000, /* 1s */
5000, /* 5s */
10000, /* 10s */
30000, /* 30s */
60000 /* 60s */
};
static const size_t hs_metrics_circ_build_time_buckets_size =
ARRAY_LENGTH(hs_metrics_circ_build_time_buckets);
/** The base metrics that is a static array of metrics that are added to every
* single new stores.
*
* The key member MUST be also the index of the entry in the array. */
const hs_metrics_entry_t base_metrics[] =
{
{
.key = HS_METRICS_NUM_INTRODUCTIONS,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_intro_num_total),
.help = "Total number of introduction received",
.port_as_label = false,
},
{
.key = HS_METRICS_APP_WRITE_BYTES,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_app_write_bytes_total),
.help = "Total number of bytes written to the application",
.port_as_label = true,
},
{
.key = HS_METRICS_APP_READ_BYTES,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_app_read_bytes_total),
.help = "Total number of bytes read from the application",
.port_as_label = true,
},
{
.key = HS_METRICS_NUM_ESTABLISHED_RDV,
.type = METRICS_TYPE_GAUGE,
.name = METRICS_NAME(hs_rdv_established_count),
.help = "Total number of established rendezvous circuits",
},
{
.key = HS_METRICS_NUM_RDV,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_rdv_num_total),
.help = "Total number of rendezvous circuits created",
},
{
.key = HS_METRICS_NUM_FAILED_RDV,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_rdv_error_count),
.help = "Total number of rendezvous circuit errors",
},
{
.key = HS_METRICS_NUM_ESTABLISHED_INTRO,
.type = METRICS_TYPE_GAUGE,
.name = METRICS_NAME(hs_intro_established_count),
.help = "Total number of established introduction circuit",
},
{
.key = HS_METRICS_NUM_REJECTED_INTRO_REQ,
.type = METRICS_TYPE_COUNTER,
.name = METRICS_NAME(hs_intro_rejected_intro_req_count),
.help = "Total number of rejected introduction circuits",
},
{
.key = HS_METRICS_INTRO_CIRC_BUILD_TIME,
.type = METRICS_TYPE_HISTOGRAM,
.name = METRICS_NAME(hs_intro_circ_build_time),
.buckets = hs_metrics_circ_build_time_buckets,
.bucket_count = hs_metrics_circ_build_time_buckets_size,
.help = "The introduction circuit build time in milliseconds",
},
{
.key = HS_METRICS_REND_CIRC_BUILD_TIME,
.type = METRICS_TYPE_HISTOGRAM,
.name = METRICS_NAME(hs_rend_circ_build_time),
.buckets = hs_metrics_circ_build_time_buckets,
.bucket_count = hs_metrics_circ_build_time_buckets_size,
.help = "The rendezvous circuit build time in milliseconds",
},
{
.key = HS_METRICS_POW_NUM_PQUEUE_RDV,
.type = METRICS_TYPE_GAUGE,
.name = METRICS_NAME(hs_rdv_pow_pqueue_count),
.help = "Number of requests waiting in the proof of work priority queue",
},
{
.key = HS_METRICS_POW_SUGGESTED_EFFORT,
.type = METRICS_TYPE_GAUGE,
.name = METRICS_NAME(hs_pow_suggested_effort),
.help = "Suggested effort for requests with a proof of work client puzzle",
},
};
/** Size of base_metrics array that is number of entries. */
const size_t base_metrics_size = ARRAY_LENGTH(base_metrics);
/** Possible values for the reason label of the
* hs_intro_rejected_intro_req_count metric. */
const char *hs_metrics_intro_req_error_reasons[] =
{
HS_METRICS_ERR_INTRO_REQ_BAD_AUTH_KEY,
HS_METRICS_ERR_INTRO_REQ_INTRODUCE2,
HS_METRICS_ERR_INTRO_REQ_SUBCREDENTIAL,
HS_METRICS_ERR_INTRO_REQ_INTRODUCE2_REPLAY,
};
/** The number of entries in the hs_metrics_intro_req_error_reasons array. */
const size_t hs_metrics_intro_req_error_reasons_size =
ARRAY_LENGTH(hs_metrics_intro_req_error_reasons);
/** Possible values for the reason label of the hs_rdv_error_count metric. */
const char *hs_metrics_rend_error_reasons[] =
{
HS_METRICS_ERR_RDV_RP_CONN_FAILURE,
HS_METRICS_ERR_RDV_PATH,
HS_METRICS_ERR_RDV_RENDEZVOUS1,
HS_METRICS_ERR_RDV_E2E,
HS_METRICS_ERR_RDV_RETRY,
};
/** The number of entries in the hs_metrics_rend_error_reasons array. */
const size_t hs_metrics_rend_error_reasons_size =
ARRAY_LENGTH(hs_metrics_rend_error_reasons);
|