Skip to content

Commit bee8b84

Browse files
authored
chore(metrics) simplify 'ngx_wa_metrics_histogram_record' arguments
The `mid` argument was only used when logging the histogram in debug mode. Since our tests don't assert on the actual value of `mid`, we don't really need to have it printed in logs. Also, `ngx_wa_metrics_record` already prints the `mid` of the metric being updated.
1 parent 070f371 commit bee8b84

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

Diff for: src/common/debug/ngx_wasm_debug_module.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ngx_wasm_debug_init(ngx_cycle_t *cycle)
112112

113113
ngx_wa_assert(
114114
ngx_wa_metrics_histogram_record(ngx_wasmx_metrics(cycle),
115-
m, 0, 0, 1) == NGX_ERROR
115+
m, 0, 1) == NGX_ERROR
116116
);
117117

118118
ngx_wa_metrics_histogram_get(ngx_wasmx_metrics(cycle), m, 1, h2);

Diff for: src/common/metrics/ngx_wa_histogram.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ histogram_log2_bin(ngx_wa_metrics_t *metrics, ngx_wa_metrics_histogram_t *h,
143143

144144
#if (NGX_DEBUG)
145145
static void
146-
histogram_log(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m, uint32_t mid)
146+
histogram_log(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m)
147147
{
148148
size_t i;
149149
u_char *p;
@@ -172,9 +172,9 @@ histogram_log(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m, uint32_t mid)
172172

173173
p = ngx_sprintf(p, " SUM: %uD;", h->sum);
174174

175-
ngx_log_debug3(NGX_LOG_DEBUG_WASM, metrics->shm->log, 0,
176-
"histogram \"%uD\": %*s",
177-
mid, p - s_buf - 1, s_buf + 1);
175+
ngx_log_debug2(NGX_LOG_DEBUG_WASM, metrics->shm->log, 0,
176+
"histogram: %*s",
177+
p - s_buf - 1, s_buf + 1);
178178
}
179179
#endif
180180

@@ -239,7 +239,7 @@ ngx_wa_metrics_histogram_add_locked(ngx_wa_metrics_t *metrics, uint32_t *bins,
239239

240240
ngx_int_t
241241
ngx_wa_metrics_histogram_record(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m,
242-
ngx_uint_t slot, uint32_t mid, ngx_uint_t n)
242+
ngx_uint_t slot, ngx_uint_t n)
243243
{
244244
ngx_wa_metrics_bin_t *b;
245245
ngx_wa_metrics_histogram_t *h;
@@ -263,7 +263,7 @@ ngx_wa_metrics_histogram_record(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m,
263263
b->count += 1;
264264

265265
#if (NGX_DEBUG)
266-
histogram_log(metrics, m, mid);
266+
histogram_log(metrics, m);
267267
#endif
268268

269269
return NGX_OK;

Diff for: src/common/metrics/ngx_wa_metrics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ ngx_wa_metrics_record(ngx_wa_metrics_t *metrics, uint32_t mid, ngx_int_t n)
454454
break;
455455

456456
case NGX_WA_METRIC_HISTOGRAM:
457-
ngx_wa_metrics_histogram_record(metrics, m, slot, mid, n);
457+
ngx_wa_metrics_histogram_record(metrics, m, slot, n);
458458
break;
459459

460460
default:

Diff for: src/common/metrics/ngx_wa_metrics.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ngx_int_t ngx_wa_metrics_get(ngx_wa_metrics_t *metrics, uint32_t metric_id,
104104
ngx_int_t ngx_wa_metrics_histogram_add_locked(ngx_wa_metrics_t *metrics,
105105
uint32_t *bins, uint16_t n_bins, ngx_wa_metric_t *m);
106106
ngx_int_t ngx_wa_metrics_histogram_record(ngx_wa_metrics_t *metrics,
107-
ngx_wa_metric_t *m, ngx_uint_t slot, uint32_t mid, ngx_uint_t n);
107+
ngx_wa_metric_t *m, ngx_uint_t slot, ngx_uint_t n);
108108
void ngx_wa_metrics_histogram_get(ngx_wa_metrics_t *metrics, ngx_wa_metric_t *m,
109109
ngx_uint_t slots, ngx_wa_metrics_histogram_t *out);
110110

Diff for: t/03-proxy_wasm/hfuncs/metrics/020-proxy_record_metric.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ qq{
8181
--- error_log eval
8282
[
8383
"growing histogram",
84-
qr/histogram "\d+": 1: 1; 2: 1; 4: 1; 8: 1; 16: 1; 32: 1; 64: 1; 128: 1; 256: 1; 512: 1; 1024: 1; 2048: 1; 4096: 1; 8192: 1; 16384: 1; 32768: 1; 65536: 1; 4294967295: 1; SUM: 262143/
84+
qr/histogram: 1: 1; 2: 1; 4: 1; 8: 1; 16: 1; 32: 1; 64: 1; 128: 1; 256: 1; 512: 1; 1024: 1; 2048: 1; 4096: 1; 8192: 1; 16384: 1; 32768: 1; 65536: 1; 4294967295: 1; SUM: 262143/
8585
]
8686
--- no_error_log
8787
[error]

Diff for: t/03-proxy_wasm/hfuncs/metrics/021-proxy_record_metric_edge_cases.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ qq{
118118
--- error_log eval
119119
[
120120
"cannot expand histogram",
121-
qr/histogram \"\d+\": 1: 1; 2: 1; 4: 1; 8: 1; 4294967295: 1; SUM: 31/,
121+
qr/histogram: 1: 1; 2: 1; 4: 1; 8: 1; 4294967295: 1; SUM: 31/,
122122
]
123123
--- no_error_log
124124
[error]

Diff for: t/06-others/021-histograms_sighup.t

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ qq{
3232
echo ok;
3333
}
3434
}
35-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
35+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
3636
--- grep_error_log_out eval
3737
$::total += $::workers;
38-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
38+
qr/histogram: 1: $::total; 4294967295: 0;/
3939
--- no_error_log
4040
[error]
4141
[crit]
@@ -54,10 +54,10 @@ qq{
5454
echo ok;
5555
}
5656
}
57-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
57+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
5858
--- grep_error_log_out eval
5959
$::total += $::workers;
60-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
60+
qr/histogram: 1: $::total; 4294967295: 0;/
6161
--- no_error_log
6262
[error]
6363
[crit]
@@ -77,10 +77,10 @@ qq{
7777
echo ok;
7878
}
7979
}
80-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
80+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
8181
--- grep_error_log_out eval
8282
$::total += 4;
83-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
83+
qr/histogram: 1: $::total; 4294967295: 0;/
8484
--- no_error_log
8585
[error]
8686
[crit]
@@ -100,10 +100,10 @@ qq{
100100
echo ok;
101101
}
102102
}
103-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
103+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
104104
--- grep_error_log_out eval
105105
$::total += 2;
106-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
106+
qr/histogram: 1: $::total; 4294967295: 0;/
107107
--- no_error_log
108108
[error]
109109
[crit]
@@ -133,10 +133,10 @@ qq{
133133
echo ok;
134134
}
135135
}
136-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
136+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
137137
--- grep_error_log_out eval
138138
$::total += 1;
139-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
139+
qr/histogram: 1: $::total; 4294967295: 0;/
140140
--- no_error_log
141141
[error]
142142
[crit]
@@ -166,10 +166,10 @@ qq{
166166
echo ok;
167167
}
168168
}
169-
--- grep_error_log eval: qr/histogram "\d+":( \d+: \d+;)+/
169+
--- grep_error_log eval: qr/histogram:( \d+: \d+;)+/
170170
--- grep_error_log_out eval
171171
$::total += 1;
172-
qr/histogram "\d+": 1: $::total; 4294967295: 0;/
172+
qr/histogram: 1: $::total; 4294967295: 0;/
173173
--- no_error_log
174174
[error]
175175
[crit]

0 commit comments

Comments
 (0)