@cryptotaxi247 / netdata-1 / commits / 6fcda4c2c

go.d weblog ignore reqProcTime on HTTP 101 (#17717)

Ilya Mashchenko committed May 20, 2024 at 20:15 UTC 6fcda4c2c007ce9bd46dc7b2825acf5c61700200
2 files changed +50 -46
src/go/collectors/go.d.plugin/modules/weblog/collect.go
+5 -1
@@ -5,6 +5,7 @@ package weblog
5 import (
6 "fmt"
7 "io"
8 + "net/http"
9 "runtime"
10 "strconv"
11 "strings"
@@ -76,6 +77,10 @@ func (w *WebLog) collectLogLines() (int, error) {
77 }
78
79 func (w *WebLog) collectLogLine() {
80 + // https://github.com/netdata/netdata/issues/17716
81 + if w.line.hasReqProcTime() && w.line.respCode == http.StatusSwitchingProtocols {
82 + w.line.reqProcTime = emptyNumber
83 + }
84 w.mx.Requests.Inc()
85 w.collectVhost()
86 w.collectPort()
@@ -309,7 +314,6 @@ func (w *WebLog) collectURLPatternStats(name string) {
314 if w.line.hasRespSize() {
315 v.BytesSent.Add(float64(w.line.respSize))
316 }
312 -
317 if w.line.hasReqProcTime() {
318 v.ReqProcTime.Observe(w.line.reqProcTime)
319 }
src/go/collectors/go.d.plugin/modules/weblog/weblog_test.go
+45 -45
@@ -140,6 +140,24 @@ func TestWebLog_Collect(t *testing.T) {
140 "custom_field_drink_wine": 231,
141 "custom_field_side_dark": 231,
142 "custom_field_side_light": 221,
143 + "custom_time_field_random_time_field_time_avg": 230,
144 + "custom_time_field_random_time_field_time_count": 452,
145 + "custom_time_field_random_time_field_time_hist_bucket_1": 452,
146 + "custom_time_field_random_time_field_time_hist_bucket_10": 452,
147 + "custom_time_field_random_time_field_time_hist_bucket_11": 452,
148 + "custom_time_field_random_time_field_time_hist_bucket_2": 452,
149 + "custom_time_field_random_time_field_time_hist_bucket_3": 452,
150 + "custom_time_field_random_time_field_time_hist_bucket_4": 452,
151 + "custom_time_field_random_time_field_time_hist_bucket_5": 452,
152 + "custom_time_field_random_time_field_time_hist_bucket_6": 452,
153 + "custom_time_field_random_time_field_time_hist_bucket_7": 452,
154 + "custom_time_field_random_time_field_time_hist_bucket_8": 452,
155 + "custom_time_field_random_time_field_time_hist_bucket_9": 452,
156 + "custom_time_field_random_time_field_time_hist_count": 452,
157 + "custom_time_field_random_time_field_time_hist_sum": 103960,
158 + "custom_time_field_random_time_field_time_max": 230,
159 + "custom_time_field_random_time_field_time_min": 230,
160 + "custom_time_field_random_time_field_time_sum": 103960,
161 "req_http_scheme": 218,
162 "req_https_scheme": 234,
163 "req_ipv4": 275,
@@ -152,24 +170,24 @@ func TestWebLog_Collect(t *testing.T) {
170 "req_port_82": 84,
171 "req_port_83": 85,
172 "req_port_84": 87,
155 - "req_proc_time_avg": 247,
156 - "req_proc_time_count": 452,
157 - "req_proc_time_hist_bucket_1": 452,
158 - "req_proc_time_hist_bucket_10": 452,
159 - "req_proc_time_hist_bucket_11": 452,
160 - "req_proc_time_hist_bucket_2": 452,
161 - "req_proc_time_hist_bucket_3": 452,
162 - "req_proc_time_hist_bucket_4": 452,
163 - "req_proc_time_hist_bucket_5": 452,
164 - "req_proc_time_hist_bucket_6": 452,
165 - "req_proc_time_hist_bucket_7": 452,
166 - "req_proc_time_hist_bucket_8": 452,
167 - "req_proc_time_hist_bucket_9": 452,
168 - "req_proc_time_hist_count": 452,
169 - "req_proc_time_hist_sum": 111927,
170 - "req_proc_time_max": 499,
173 + "req_proc_time_avg": 244,
174 + "req_proc_time_count": 402,
175 + "req_proc_time_hist_bucket_1": 402,
176 + "req_proc_time_hist_bucket_10": 402,
177 + "req_proc_time_hist_bucket_11": 402,
178 + "req_proc_time_hist_bucket_2": 402,
179 + "req_proc_time_hist_bucket_3": 402,
180 + "req_proc_time_hist_bucket_4": 402,
181 + "req_proc_time_hist_bucket_5": 402,
182 + "req_proc_time_hist_bucket_6": 402,
183 + "req_proc_time_hist_bucket_7": 402,
184 + "req_proc_time_hist_bucket_8": 402,
185 + "req_proc_time_hist_bucket_9": 402,
186 + "req_proc_time_hist_count": 402,
187 + "req_proc_time_hist_sum": 98312,
188 + "req_proc_time_max": 497,
189 "req_proc_time_min": 2,
172 - "req_proc_time_sum": 111927,
190 + "req_proc_time_sum": 98312,
191 "req_ssl_cipher_suite_AES256-SHA": 101,
192 "req_ssl_cipher_suite_DHE-RSA-AES256-SHA": 111,
193 "req_ssl_cipher_suite_ECDHE-RSA-AES256-SHA": 127,
@@ -236,11 +254,11 @@ func TestWebLog_Collect(t *testing.T) {
254 "url_ptn_com_req_method_GET": 38,
255 "url_ptn_com_req_method_HEAD": 39,
256 "url_ptn_com_req_method_POST": 43,
239 - "url_ptn_com_req_proc_time_avg": 212,
240 - "url_ptn_com_req_proc_time_count": 120,
257 + "url_ptn_com_req_proc_time_avg": 209,
258 + "url_ptn_com_req_proc_time_count": 105,
259 "url_ptn_com_req_proc_time_max": 495,
260 "url_ptn_com_req_proc_time_min": 5,
243 - "url_ptn_com_req_proc_time_sum": 25544,
261 + "url_ptn_com_req_proc_time_sum": 22010,
262 "url_ptn_com_resp_code_100": 12,
263 "url_ptn_com_resp_code_101": 15,
264 "url_ptn_com_resp_code_200": 13,
@@ -254,11 +272,11 @@ func TestWebLog_Collect(t *testing.T) {
272 "url_ptn_net_req_method_GET": 51,
273 "url_ptn_net_req_method_HEAD": 33,
274 "url_ptn_net_req_method_POST": 32,
257 - "url_ptn_net_req_proc_time_avg": 260,
258 - "url_ptn_net_req_proc_time_count": 116,
259 - "url_ptn_net_req_proc_time_max": 499,
275 + "url_ptn_net_req_proc_time_avg": 254,
276 + "url_ptn_net_req_proc_time_count": 104,
277 + "url_ptn_net_req_proc_time_max": 497,
278 "url_ptn_net_req_proc_time_min": 10,
261 - "url_ptn_net_req_proc_time_sum": 30221,
279 + "url_ptn_net_req_proc_time_sum": 26510,
280 "url_ptn_net_resp_code_100": 16,
281 "url_ptn_net_resp_code_101": 12,
282 "url_ptn_net_resp_code_200": 16,
@@ -279,11 +297,11 @@ func TestWebLog_Collect(t *testing.T) {
297 "url_ptn_org_req_method_GET": 29,
298 "url_ptn_org_req_method_HEAD": 46,
299 "url_ptn_org_req_method_POST": 38,
282 - "url_ptn_org_req_proc_time_avg": 263,
283 - "url_ptn_org_req_proc_time_count": 113,
300 + "url_ptn_org_req_proc_time_avg": 260,
301 + "url_ptn_org_req_proc_time_count": 102,
302 "url_ptn_org_req_proc_time_max": 497,
303 "url_ptn_org_req_proc_time_min": 2,
286 - "url_ptn_org_req_proc_time_sum": 29796,
304 + "url_ptn_org_req_proc_time_sum": 26599,
305 "url_ptn_org_resp_code_100": 15,
306 "url_ptn_org_resp_code_101": 11,
307 "url_ptn_org_resp_code_200": 20,
@@ -292,24 +310,6 @@ func TestWebLog_Collect(t *testing.T) {
310 "url_ptn_org_resp_code_301": 19,
311 "url_ptn_org_resp_code_400": 13,
312 "url_ptn_org_resp_code_401": 9,
295 - "custom_time_field_random_time_field_time_avg": 230,
296 - "custom_time_field_random_time_field_time_count": 452,
297 - "custom_time_field_random_time_field_time_hist_bucket_1": 452,
298 - "custom_time_field_random_time_field_time_hist_bucket_10": 452,
299 - "custom_time_field_random_time_field_time_hist_bucket_11": 452,
300 - "custom_time_field_random_time_field_time_hist_bucket_2": 452,
301 - "custom_time_field_random_time_field_time_hist_bucket_3": 452,
302 - "custom_time_field_random_time_field_time_hist_bucket_4": 452,
303 - "custom_time_field_random_time_field_time_hist_bucket_5": 452,
304 - "custom_time_field_random_time_field_time_hist_bucket_6": 452,
305 - "custom_time_field_random_time_field_time_hist_bucket_7": 452,
306 - "custom_time_field_random_time_field_time_hist_bucket_8": 452,
307 - "custom_time_field_random_time_field_time_hist_bucket_9": 452,
308 - "custom_time_field_random_time_field_time_hist_count": 452,
309 - "custom_time_field_random_time_field_time_hist_sum": 103960,
310 - "custom_time_field_random_time_field_time_max": 230,
311 - "custom_time_field_random_time_field_time_min": 230,
312 - "custom_time_field_random_time_field_time_sum": 103960,
313 }
314
315 mx := weblog.Collect()