diff --git a/common/network_manager.go b/common/network_manager.go index 88bae6671..1fea23b46 100644 --- a/common/network_manager.go +++ b/common/network_manager.go @@ -223,7 +223,7 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) { Time: wallTime, }, { - TimeSeries: k6metrics.TimeSeries{Metric: state.BuiltinMetrics.HTTPReqDuration, Tags: tags}, + TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqDuration, Tags: tags}, Value: k6metrics.D(wallTime.Sub(req.wallTime)), Time: wallTime, }, diff --git a/k6ext/metrics.go b/k6ext/metrics.go index db93ea3a0..41678cefd 100644 --- a/k6ext/metrics.go +++ b/k6ext/metrics.go @@ -21,16 +21,18 @@ const ( inpName = "browser_web_vital_inp" fcpName = "browser_web_vital_fcp" - browserDataSentName = "browser_data_sent" - browserHTTPReqsName = "browser_http_reqs" + browserDataSentName = "browser_data_sent" + browserHTTPReqsName = "browser_http_reqs" + browserHTTPReqDurationName = "browser_http_req_duration" ) // CustomMetrics are the custom k6 metrics used by xk6-browser. type CustomMetrics struct { WebVitals map[string]*k6metrics.Metric - BrowserDataSent *k6metrics.Metric - BrowserHTTPReqs *k6metrics.Metric + BrowserDataSent *k6metrics.Metric + BrowserHTTPReqs *k6metrics.Metric + BrowserHTTPReqDuration *k6metrics.Metric } // RegisterCustomMetrics creates and registers our custom metrics with the k6 @@ -65,9 +67,10 @@ func RegisterCustomMetrics(registry *k6metrics.Registry) *CustomMetrics { } return &CustomMetrics{ - WebVitals: webVitals, - BrowserDataSent: registry.MustNewMetric(browserDataSentName, k6metrics.Counter, k6metrics.Data), - BrowserHTTPReqs: registry.MustNewMetric(browserHTTPReqsName, k6metrics.Counter), + WebVitals: webVitals, + BrowserDataSent: registry.MustNewMetric(browserDataSentName, k6metrics.Counter, k6metrics.Data), + BrowserHTTPReqs: registry.MustNewMetric(browserHTTPReqsName, k6metrics.Counter), + BrowserHTTPReqDuration: registry.MustNewMetric(browserHTTPReqDurationName, k6metrics.Trend, k6metrics.Time), } }