Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some of the http metrics #916

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions common/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion common/network_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
}
41 changes: 13 additions & 28 deletions k6ext/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
}
}

Expand Down