Tor 0.4.9.0-alpha-dev
hs_metrics_entry.c
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 hs_metrics_entry.c
6 * @brief Defines the metrics entry that are collected by an onion service.
7 **/
8
9#define HS_METRICS_ENTRY_PRIVATE
10
11#include <stddef.h>
12
13#include "orconfig.h"
14
16#include "lib/log/log.h"
17#include "lib/log/util_bug.h"
18
20
21/* Histogram time buckets (in milliseconds). */
22static const int64_t hs_metrics_circ_build_time_buckets[] =
23{
24 1000, /* 1s */
25 5000, /* 5s */
26 10000, /* 10s */
27 30000, /* 30s */
28 60000 /* 60s */
29};
30
31// TODO: Define a constant for ARRAY_LENGTH(hs_metrics_circ_build_time_buckets)
32// and use where it applicable.
33//
34// This is commented out because it doesn't compile with gcc versions < 8.1
35// or with MSVC ("initializer element is not constant").
36//
37// See ticket#40773 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960#c18
38//
39/*static const size_t hs_metrics_circ_build_time_buckets_size =*/
40/*ARRAY_LENGTH(hs_metrics_circ_build_time_buckets);*/
41
42/** The base metrics that is a static array of metrics that are added to every
43 * single new stores.
44 *
45 * The key member MUST be also the index of the entry in the array. */
46const hs_metrics_entry_t base_metrics[] =
47{
48 {
49 .key = HS_METRICS_NUM_INTRODUCTIONS,
50 .type = METRICS_TYPE_COUNTER,
51 .name = METRICS_NAME(hs_intro_num_total),
52 .help = "Total number of introduction received",
53 .port_as_label = false,
54 },
55 {
56 .key = HS_METRICS_APP_WRITE_BYTES,
57 .type = METRICS_TYPE_COUNTER,
58 .name = METRICS_NAME(hs_app_write_bytes_total),
59 .help = "Total number of bytes written to the application",
60 .port_as_label = true,
61 },
62 {
63 .key = HS_METRICS_APP_READ_BYTES,
64 .type = METRICS_TYPE_COUNTER,
65 .name = METRICS_NAME(hs_app_read_bytes_total),
66 .help = "Total number of bytes read from the application",
67 .port_as_label = true,
68 },
69 {
70 .key = HS_METRICS_NUM_ESTABLISHED_RDV,
71 .type = METRICS_TYPE_GAUGE,
72 .name = METRICS_NAME(hs_rdv_established_count),
73 .help = "Total number of established rendezvous circuits",
74 },
75 {
76 .key = HS_METRICS_NUM_RDV,
77 .type = METRICS_TYPE_COUNTER,
78 .name = METRICS_NAME(hs_rdv_num_total),
79 .help = "Total number of rendezvous circuits created",
80 },
81 {
82 .key = HS_METRICS_NUM_FAILED_RDV,
83 .type = METRICS_TYPE_COUNTER,
84 .name = METRICS_NAME(hs_rdv_error_count),
85 .help = "Total number of rendezvous circuit errors",
86 },
87 {
88 .key = HS_METRICS_NUM_ESTABLISHED_INTRO,
89 .type = METRICS_TYPE_GAUGE,
90 .name = METRICS_NAME(hs_intro_established_count),
91 .help = "Total number of established introduction circuit",
92 },
93 {
94 .key = HS_METRICS_NUM_REJECTED_INTRO_REQ,
95 .type = METRICS_TYPE_COUNTER,
96 .name = METRICS_NAME(hs_intro_rejected_intro_req_count),
97 .help = "Total number of rejected introduction circuits",
98 },
99 {
100 .key = HS_METRICS_INTRO_CIRC_BUILD_TIME,
101 .type = METRICS_TYPE_HISTOGRAM,
102 .name = METRICS_NAME(hs_intro_circ_build_time),
103 .buckets = hs_metrics_circ_build_time_buckets,
104 .bucket_count = ARRAY_LENGTH(hs_metrics_circ_build_time_buckets),
105 .help = "The introduction circuit build time in milliseconds",
106 },
107 {
108 .key = HS_METRICS_REND_CIRC_BUILD_TIME,
109 .type = METRICS_TYPE_HISTOGRAM,
110 .name = METRICS_NAME(hs_rend_circ_build_time),
111 .buckets = hs_metrics_circ_build_time_buckets,
112 .bucket_count = ARRAY_LENGTH(hs_metrics_circ_build_time_buckets),
113 .help = "The rendezvous circuit build time in milliseconds",
114 },
115 {
116 .key = HS_METRICS_POW_NUM_PQUEUE_RDV,
117 .type = METRICS_TYPE_GAUGE,
118 .name = METRICS_NAME(hs_rdv_pow_pqueue_count),
119 .help = "Number of requests waiting in the proof of work priority queue",
120 },
121 {
122 .key = HS_METRICS_POW_SUGGESTED_EFFORT,
123 .type = METRICS_TYPE_GAUGE,
124 .name = METRICS_NAME(hs_pow_suggested_effort),
125 .help = "Suggested effort for requests with a proof of work client puzzle",
126 },
127};
128
129/** Size of base_metrics array that is number of entries. */
131
132/** Possible values for the reason label of the
133 * hs_intro_rejected_intro_req_count metric. */
135{
136 HS_METRICS_ERR_INTRO_REQ_BAD_AUTH_KEY,
137 HS_METRICS_ERR_INTRO_REQ_INTRODUCE2,
138 HS_METRICS_ERR_INTRO_REQ_SUBCREDENTIAL,
139 HS_METRICS_ERR_INTRO_REQ_INTRODUCE2_REPLAY,
140};
141
142/** The number of entries in the hs_metrics_intro_req_error_reasons array. */
145
146/** Possible values for the reason label of the hs_rdv_error_count metric. */
148{
149 HS_METRICS_ERR_RDV_RP_CONN_FAILURE,
150 HS_METRICS_ERR_RDV_PATH,
151 HS_METRICS_ERR_RDV_RENDEZVOUS1,
152 HS_METRICS_ERR_RDV_E2E,
153 HS_METRICS_ERR_RDV_RETRY,
154};
155
156/** The number of entries in the hs_metrics_rend_error_reasons array. */
Utility macros to handle different features and behavior in different compilers.
#define ARRAY_LENGTH(x)
const char * hs_metrics_rend_error_reasons[]
const hs_metrics_entry_t base_metrics[]
const size_t hs_metrics_intro_req_error_reasons_size
const size_t base_metrics_size
const char * hs_metrics_intro_req_error_reasons[]
const size_t hs_metrics_rend_error_reasons_size
Header for feature/hs/hs_metrics_entry.c.
Headers for log.c.
Macros to manage assertions, fatal and non-fatal.