Skip to content

Commit

Permalink
go.d weblog ignore reqProcTime on HTTP 101 (netdata#17717)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored May 20, 2024
1 parent 9cff282 commit 6fcda4c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
6 changes: 5 additions & 1 deletion src/go/collectors/go.d.plugin/modules/weblog/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package weblog
import (
"fmt"
"io"
"net/http"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -76,6 +77,10 @@ func (w *WebLog) collectLogLines() (int, error) {
}

func (w *WebLog) collectLogLine() {
// https://github.com/netdata/netdata/issues/17716
if w.line.hasReqProcTime() && w.line.respCode == http.StatusSwitchingProtocols {
w.line.reqProcTime = emptyNumber
}
w.mx.Requests.Inc()
w.collectVhost()
w.collectPort()
Expand Down Expand Up @@ -309,7 +314,6 @@ func (w *WebLog) collectURLPatternStats(name string) {
if w.line.hasRespSize() {
v.BytesSent.Add(float64(w.line.respSize))
}

if w.line.hasReqProcTime() {
v.ReqProcTime.Observe(w.line.reqProcTime)
}
Expand Down
90 changes: 45 additions & 45 deletions src/go/collectors/go.d.plugin/modules/weblog/weblog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ func TestWebLog_Collect(t *testing.T) {
"custom_field_drink_wine": 231,
"custom_field_side_dark": 231,
"custom_field_side_light": 221,
"custom_time_field_random_time_field_time_avg": 230,
"custom_time_field_random_time_field_time_count": 452,
"custom_time_field_random_time_field_time_hist_bucket_1": 452,
"custom_time_field_random_time_field_time_hist_bucket_10": 452,
"custom_time_field_random_time_field_time_hist_bucket_11": 452,
"custom_time_field_random_time_field_time_hist_bucket_2": 452,
"custom_time_field_random_time_field_time_hist_bucket_3": 452,
"custom_time_field_random_time_field_time_hist_bucket_4": 452,
"custom_time_field_random_time_field_time_hist_bucket_5": 452,
"custom_time_field_random_time_field_time_hist_bucket_6": 452,
"custom_time_field_random_time_field_time_hist_bucket_7": 452,
"custom_time_field_random_time_field_time_hist_bucket_8": 452,
"custom_time_field_random_time_field_time_hist_bucket_9": 452,
"custom_time_field_random_time_field_time_hist_count": 452,
"custom_time_field_random_time_field_time_hist_sum": 103960,
"custom_time_field_random_time_field_time_max": 230,
"custom_time_field_random_time_field_time_min": 230,
"custom_time_field_random_time_field_time_sum": 103960,
"req_http_scheme": 218,
"req_https_scheme": 234,
"req_ipv4": 275,
Expand All @@ -152,24 +170,24 @@ func TestWebLog_Collect(t *testing.T) {
"req_port_82": 84,
"req_port_83": 85,
"req_port_84": 87,
"req_proc_time_avg": 247,
"req_proc_time_count": 452,
"req_proc_time_hist_bucket_1": 452,
"req_proc_time_hist_bucket_10": 452,
"req_proc_time_hist_bucket_11": 452,
"req_proc_time_hist_bucket_2": 452,
"req_proc_time_hist_bucket_3": 452,
"req_proc_time_hist_bucket_4": 452,
"req_proc_time_hist_bucket_5": 452,
"req_proc_time_hist_bucket_6": 452,
"req_proc_time_hist_bucket_7": 452,
"req_proc_time_hist_bucket_8": 452,
"req_proc_time_hist_bucket_9": 452,
"req_proc_time_hist_count": 452,
"req_proc_time_hist_sum": 111927,
"req_proc_time_max": 499,
"req_proc_time_avg": 244,
"req_proc_time_count": 402,
"req_proc_time_hist_bucket_1": 402,
"req_proc_time_hist_bucket_10": 402,
"req_proc_time_hist_bucket_11": 402,
"req_proc_time_hist_bucket_2": 402,
"req_proc_time_hist_bucket_3": 402,
"req_proc_time_hist_bucket_4": 402,
"req_proc_time_hist_bucket_5": 402,
"req_proc_time_hist_bucket_6": 402,
"req_proc_time_hist_bucket_7": 402,
"req_proc_time_hist_bucket_8": 402,
"req_proc_time_hist_bucket_9": 402,
"req_proc_time_hist_count": 402,
"req_proc_time_hist_sum": 98312,
"req_proc_time_max": 497,
"req_proc_time_min": 2,
"req_proc_time_sum": 111927,
"req_proc_time_sum": 98312,
"req_ssl_cipher_suite_AES256-SHA": 101,
"req_ssl_cipher_suite_DHE-RSA-AES256-SHA": 111,
"req_ssl_cipher_suite_ECDHE-RSA-AES256-SHA": 127,
Expand Down Expand Up @@ -236,11 +254,11 @@ func TestWebLog_Collect(t *testing.T) {
"url_ptn_com_req_method_GET": 38,
"url_ptn_com_req_method_HEAD": 39,
"url_ptn_com_req_method_POST": 43,
"url_ptn_com_req_proc_time_avg": 212,
"url_ptn_com_req_proc_time_count": 120,
"url_ptn_com_req_proc_time_avg": 209,
"url_ptn_com_req_proc_time_count": 105,
"url_ptn_com_req_proc_time_max": 495,
"url_ptn_com_req_proc_time_min": 5,
"url_ptn_com_req_proc_time_sum": 25544,
"url_ptn_com_req_proc_time_sum": 22010,
"url_ptn_com_resp_code_100": 12,
"url_ptn_com_resp_code_101": 15,
"url_ptn_com_resp_code_200": 13,
Expand All @@ -254,11 +272,11 @@ func TestWebLog_Collect(t *testing.T) {
"url_ptn_net_req_method_GET": 51,
"url_ptn_net_req_method_HEAD": 33,
"url_ptn_net_req_method_POST": 32,
"url_ptn_net_req_proc_time_avg": 260,
"url_ptn_net_req_proc_time_count": 116,
"url_ptn_net_req_proc_time_max": 499,
"url_ptn_net_req_proc_time_avg": 254,
"url_ptn_net_req_proc_time_count": 104,
"url_ptn_net_req_proc_time_max": 497,
"url_ptn_net_req_proc_time_min": 10,
"url_ptn_net_req_proc_time_sum": 30221,
"url_ptn_net_req_proc_time_sum": 26510,
"url_ptn_net_resp_code_100": 16,
"url_ptn_net_resp_code_101": 12,
"url_ptn_net_resp_code_200": 16,
Expand All @@ -279,11 +297,11 @@ func TestWebLog_Collect(t *testing.T) {
"url_ptn_org_req_method_GET": 29,
"url_ptn_org_req_method_HEAD": 46,
"url_ptn_org_req_method_POST": 38,
"url_ptn_org_req_proc_time_avg": 263,
"url_ptn_org_req_proc_time_count": 113,
"url_ptn_org_req_proc_time_avg": 260,
"url_ptn_org_req_proc_time_count": 102,
"url_ptn_org_req_proc_time_max": 497,
"url_ptn_org_req_proc_time_min": 2,
"url_ptn_org_req_proc_time_sum": 29796,
"url_ptn_org_req_proc_time_sum": 26599,
"url_ptn_org_resp_code_100": 15,
"url_ptn_org_resp_code_101": 11,
"url_ptn_org_resp_code_200": 20,
Expand All @@ -292,24 +310,6 @@ func TestWebLog_Collect(t *testing.T) {
"url_ptn_org_resp_code_301": 19,
"url_ptn_org_resp_code_400": 13,
"url_ptn_org_resp_code_401": 9,
"custom_time_field_random_time_field_time_avg": 230,
"custom_time_field_random_time_field_time_count": 452,
"custom_time_field_random_time_field_time_hist_bucket_1": 452,
"custom_time_field_random_time_field_time_hist_bucket_10": 452,
"custom_time_field_random_time_field_time_hist_bucket_11": 452,
"custom_time_field_random_time_field_time_hist_bucket_2": 452,
"custom_time_field_random_time_field_time_hist_bucket_3": 452,
"custom_time_field_random_time_field_time_hist_bucket_4": 452,
"custom_time_field_random_time_field_time_hist_bucket_5": 452,
"custom_time_field_random_time_field_time_hist_bucket_6": 452,
"custom_time_field_random_time_field_time_hist_bucket_7": 452,
"custom_time_field_random_time_field_time_hist_bucket_8": 452,
"custom_time_field_random_time_field_time_hist_bucket_9": 452,
"custom_time_field_random_time_field_time_hist_count": 452,
"custom_time_field_random_time_field_time_hist_sum": 103960,
"custom_time_field_random_time_field_time_max": 230,
"custom_time_field_random_time_field_time_min": 230,
"custom_time_field_random_time_field_time_sum": 103960,
}

mx := weblog.Collect()
Expand Down

0 comments on commit 6fcda4c

Please sign in to comment.