Skip to content

Commit

Permalink
Add browser_http_req_receiving metric
Browse files Browse the repository at this point in the history
This commit helps us move away from the k6 http_req_receiving metric to
a browser prefixed one. It is custom to the browser module allowing the
user to measure k6 vs browser http_req_receiving metrics separately.
  • Loading branch information
ankur22 committed May 24, 2023
1 parent d712525 commit 3a32e0a
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 @@ -254,7 +254,7 @@ func (m *NetworkManager) emitResponseMetrics(resp *Response, req *Request) {
Time: wallTime,
},
{
TimeSeries: k6metrics.TimeSeries{Metric: state.BuiltinMetrics.HTTPReqReceiving, Tags: tags},
TimeSeries: k6metrics.TimeSeries{Metric: m.customMetrics.BrowserHTTPReqReceiving, Tags: tags},
Value: k6metrics.D(time.Duration(resp.timing.ReceiveHeadersEnd-resp.timing.SendEnd) * 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 @@ -28,6 +28,7 @@ const (
browserHTTPReqConnectingName = "browser_http_req_connecting"
browserHTTPReqTLSHandshakingName = "browser_http_req_tls_handshaking"
browserHTTPReqSendingName = "browser_http_req_sending"
browserHTTPReqReceivingName = "browser_http_req_receiving"
)

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

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

Expand Down

0 comments on commit 3a32e0a

Please sign in to comment.