Skip to content

Commit

Permalink
Add browser_http_req_sending metric
Browse files Browse the repository at this point in the history
This commit helps us move away from the k6 http_req_sending metric to
a browser prefixed one. It is custom to the browser module allowing the
user to measure k6 vs browser http_req_sending metrics separately.
  • Loading branch information
ankur22 committed May 23, 2023
1 parent 52a12da commit af47d14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) {
Time: wallTime,
},
{
TimeSeries: k6metrics.TimeSeries{Metric: state.BuiltinMetrics.HTTPReqSending, Tags: tags},
TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqSending, Tags: tags},
Value: k6metrics.D(time.Duration(resp.timing.SendEnd-resp.timing.SendStart) * time.Millisecond),
Time: wallTime,
},
Expand Down
3 changes: 3 additions & 0 deletions k6ext/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
browserHTTPReqDurationName = "browser_http_req_duration"
browserHTTPReqConnectingName = "browser_http_req_connecting"
browserHTTPReqTLSHandshakingName = "browser_http_req_tls_handshaking"
browserHTTPReqSendingName = "browser_http_req_sending"
)

// CustomMetrics are the custom k6 metrics used by xk6-browser.
Expand All @@ -39,6 +40,7 @@ type CustomMetrics struct {
BrowserHTTPReqDuration *k6metrics.Metric
BrowserHTTPReqConnecting *k6metrics.Metric
BrowserHTTPReqTLSHandshaking *k6metrics.Metric
BrowserHTTPReqSending *k6metrics.Metric
}

// RegisterCustomMetrics creates and registers our custom metrics with the k6
Expand Down Expand Up @@ -80,6 +82,7 @@ func RegisterCustomMetrics(registry *k6metrics.Registry) *CustomMetrics {
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),
}
}

Expand Down

0 comments on commit af47d14

Please sign in to comment.