diff --git a/common/network_manager.go b/common/network_manager.go index c90a999bc..0f4ad99ed 100644 --- a/common/network_manager.go +++ b/common/network_manager.go @@ -223,11 +223,6 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) { k6metrics.PushIfNotDone(m.ctx, state.Samples, k6metrics.ConnectedSamples{ Samples: []k6metrics.Sample{ - { - TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqs, Tags: tags}, - Value: 1, - Time: wallTime, - }, { TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqDuration, Tags: tags}, Value: k6metrics.D(wallTime.Sub(req.wallTime)), @@ -244,26 +239,6 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) { if resp != nil && resp.timing != nil { k6metrics.PushIfNotDone(m.ctx, state.Samples, k6metrics.ConnectedSamples{ Samples: []k6metrics.Sample{ - { - TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqConnecting, Tags: tags}, - Value: k6metrics.D(time.Duration(resp.timing.ConnectEnd-resp.timing.ConnectStart) * time.Millisecond), - Time: wallTime, - }, - { - TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqTLSHandshaking, Tags: tags}, - Value: k6metrics.D(time.Duration(resp.timing.SslEnd-resp.timing.SslStart) * time.Millisecond), - Time: wallTime, - }, - { - TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqSending, Tags: tags}, - Value: k6metrics.D(time.Duration(resp.timing.SendEnd-resp.timing.SendStart) * time.Millisecond), - Time: wallTime, - }, - { - TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqReceiving, Tags: tags}, - Value: k6metrics.D(time.Duration(resp.timing.ReceiveHeadersEnd-resp.timing.SendEnd) * time.Millisecond), - Time: wallTime, - }, { TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqFailed, Tags: tags}, Value: failed, diff --git a/common/network_manager_test.go b/common/network_manager_test.go index 214a02d1e..b10212022 100644 --- a/common/network_manager_test.go +++ b/common/network_manager_test.go @@ -291,7 +291,7 @@ func TestNetworkManagerEmitRequestResponseMetricsTimingSkew(t *testing.T) { n = vu.AssertSamples(func(s k6metrics.Sample) { assert.Equalf(t, tt.wantRes.wt, s.Time, "timing skew in %s", s.Metric.Name) }) - assert.Equalf(t, 8, n, "should emit 8 response metrics") + assert.Equalf(t, 3, n, "should emit 8 response metrics") }) } } diff --git a/k6ext/metrics.go b/k6ext/metrics.go index 27e5054be..2e1891960 100644 --- a/k6ext/metrics.go +++ b/k6ext/metrics.go @@ -21,30 +21,20 @@ const ( inpName = "browser_web_vital_inp" fcpName = "browser_web_vital_fcp" - browserDataSentName = "browser_data_sent" - browserDataReceivedName = "browser_data_received" - browserHTTPReqsName = "browser_http_reqs" - browserHTTPReqDurationName = "browser_http_req_duration" - browserHTTPReqConnectingName = "browser_http_req_connecting" - browserHTTPReqTLSHandshakingName = "browser_http_req_tls_handshaking" - browserHTTPReqSendingName = "browser_http_req_sending" - browserHTTPReqReceivingName = "browser_http_req_receiving" - browserHTTPReqFailedName = "browser_http_req_failed" + browserDataSentName = "browser_data_sent" + browserDataReceivedName = "browser_data_received" + browserHTTPReqDurationName = "browser_http_req_duration" + browserHTTPReqFailedName = "browser_http_req_failed" ) // CustomMetrics are the custom k6 metrics used by xk6-browser. type CustomMetrics struct { WebVitals map[string]*k6metrics.Metric - BrowserDataSent *k6metrics.Metric - BrowserDataReceived *k6metrics.Metric - BrowserHTTPReqs *k6metrics.Metric - BrowserHTTPReqDuration *k6metrics.Metric - BrowserHTTPReqConnecting *k6metrics.Metric - BrowserHTTPReqTLSHandshaking *k6metrics.Metric - BrowserHTTPReqSending *k6metrics.Metric - BrowserHTTPReqReceiving *k6metrics.Metric - BrowserHTTPReqFailed *k6metrics.Metric + BrowserDataSent *k6metrics.Metric + BrowserDataReceived *k6metrics.Metric + BrowserHTTPReqDuration *k6metrics.Metric + BrowserHTTPReqFailed *k6metrics.Metric } // RegisterCustomMetrics creates and registers our custom metrics with the k6 @@ -80,16 +70,11 @@ func RegisterCustomMetrics(registry *k6metrics.Registry) *CustomMetrics { //nolint:lll return &CustomMetrics{ - WebVitals: webVitals, - BrowserDataSent: registry.MustNewMetric(browserDataSentName, k6metrics.Counter, k6metrics.Data), - BrowserDataReceived: registry.MustNewMetric(browserDataReceivedName, k6metrics.Counter, k6metrics.Data), - BrowserHTTPReqs: registry.MustNewMetric(browserHTTPReqsName, k6metrics.Counter), - BrowserHTTPReqDuration: registry.MustNewMetric(browserHTTPReqDurationName, k6metrics.Trend, k6metrics.Time), - BrowserHTTPReqConnecting: registry.MustNewMetric(browserHTTPReqConnectingName, k6metrics.Trend, k6metrics.Time), - BrowserHTTPReqTLSHandshaking: registry.MustNewMetric(browserHTTPReqTLSHandshakingName, k6metrics.Trend, k6metrics.Time), - BrowserHTTPReqSending: registry.MustNewMetric(browserHTTPReqSendingName, k6metrics.Trend, k6metrics.Time), - BrowserHTTPReqReceiving: registry.MustNewMetric(browserHTTPReqReceivingName, k6metrics.Trend, k6metrics.Time), - BrowserHTTPReqFailed: registry.MustNewMetric(browserHTTPReqFailedName, k6metrics.Rate), + WebVitals: webVitals, + BrowserDataSent: registry.MustNewMetric(browserDataSentName, k6metrics.Counter, k6metrics.Data), + BrowserDataReceived: registry.MustNewMetric(browserDataReceivedName, k6metrics.Counter, k6metrics.Data), + BrowserHTTPReqDuration: registry.MustNewMetric(browserHTTPReqDurationName, k6metrics.Trend, k6metrics.Time), + BrowserHTTPReqFailed: registry.MustNewMetric(browserHTTPReqFailedName, k6metrics.Rate), } }