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

Flagging custom metrics #170

Merged
merged 1 commit into from
Feb 6, 2024
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
1 change: 1 addition & 0 deletions dashboard/assets/packages/model/src/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type Metric = {
contains?: ValueType
type?: MetricType
thresholds?: Array<string>
custom?: boolean
}

export class Query {
Expand Down
125 changes: 125 additions & 0 deletions dashboard/builtin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package dashboard

import (
"sort"

"go.k6.io/k6/metrics"
)

const (
// xk6-dashboard's time
keyTime = "time"

// from k6 metrics/builtin.go
keyVUsName = metrics.VUsName
keyVUsMaxName = metrics.VUsMaxName
keyIterationsName = metrics.IterationsName
keyIterationDurationName = metrics.IterationDurationName
keyDroppedIterationsName = metrics.DroppedIterationsName

keyChecksName = metrics.ChecksName
keyGroupDurationName = metrics.GroupDurationName

keyHTTPReqsName = metrics.HTTPReqsName
keyHTTPReqFailedName = metrics.HTTPReqFailedName
keyHTTPReqDurationName = metrics.HTTPReqDurationName
keyHTTPReqBlockedName = metrics.HTTPReqBlockedName
keyHTTPReqConnectingName = metrics.HTTPReqConnectingName
keyHTTPReqTLSHandshakingName = metrics.HTTPReqTLSHandshakingName
keyHTTPReqSendingName = metrics.HTTPReqSendingName
keyHTTPReqWaitingName = metrics.HTTPReqWaitingName
keyHTTPReqReceivingName = metrics.HTTPReqReceivingName

keyWSSessionsName = metrics.WSSessionsName
keyWSMessagesSentName = metrics.WSMessagesSentName
keyWSMessagesReceivedName = metrics.WSMessagesReceivedName
keyWSPingName = metrics.WSPingName
keyWSSessionDurationName = metrics.WSSessionDurationName
keyWSConnectingName = metrics.WSConnectingName

keyGRPCReqDurationName = metrics.GRPCReqDurationName

keyDataSentName = metrics.DataSentName
keyDataReceivedName = metrics.DataReceivedName

// from xk6-browser

keyfidName = "browser_web_vital_fid"
keyttfbName = "browser_web_vital_ttfb"
keylcpName = "browser_web_vital_lcp"
keyclsName = "browser_web_vital_cls"
keyinpName = "browser_web_vital_inp"
keyfcpName = "browser_web_vital_fcp"

keybrowserDataSentName = "browser_data_sent"
keybrowserDataReceivedName = "browser_data_received"
keybrowserHTTPReqDurationName = "browser_http_req_duration"
keybrowserHTTPReqFailedName = "browser_http_req_failed"

// from k6/grpc

keyGRPCStreamsName = "grpc_streams"
keyGRPCStreamsMsgsReceivedName = "grpc_streams_msgs_received"
keyGRPCStreamsMsgsSentName = "grpc_streams_msgs_sent"
)

var builtinNames = []string{ //nolint:gochecknoglobals
keyTime,

keyVUsName,
keyVUsMaxName,
keyIterationsName,
keyIterationDurationName,
keyDroppedIterationsName,

keyChecksName,
keyGroupDurationName,

keyHTTPReqsName,
keyHTTPReqFailedName,
keyHTTPReqDurationName,
keyHTTPReqBlockedName,
keyHTTPReqConnectingName,
keyHTTPReqTLSHandshakingName,
keyHTTPReqSendingName,
keyHTTPReqWaitingName,
keyHTTPReqReceivingName,

keyWSSessionsName,
keyWSMessagesSentName,
keyWSMessagesReceivedName,
keyWSPingName,
keyWSSessionDurationName,
keyWSConnectingName,

keyGRPCReqDurationName,

keyDataSentName,
keyDataReceivedName,

keyfidName,
keyttfbName,
keylcpName,
keyclsName,
keyinpName,
keyfcpName,

keybrowserDataSentName,
keybrowserDataReceivedName,
keybrowserHTTPReqDurationName,
keybrowserHTTPReqFailedName,

keyGRPCStreamsName,
keyGRPCStreamsMsgsReceivedName,
keyGRPCStreamsMsgsSentName,
}

func init() {
sort.Strings(builtinNames)
}

func isBuiltin(name string) bool {
idx := sort.SearchStrings(builtinNames, name)

return idx < len(builtinNames) && builtinNames[idx] == name
}
2 changes: 2 additions & 0 deletions dashboard/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ type metricData struct {
Contains metrics.ValueType `json:"contains,omitempty"`
Tainted bool `json:"tainted,omitempty"`
Thresholds []string `json:"thresholds,omitempty"`
Custom bool `json:"custom,omitempty"`
}

func newMetricData(origin *metrics.Metric) *metricData {
Expand All @@ -228,6 +229,7 @@ func newMetricData(origin *metrics.Metric) *metricData {
Contains: origin.Contains,
Tainted: origin.Tainted.Bool,
Thresholds: thresholdsSources(origin.Thresholds),
Custom: !isBuiltin(origin.Name),
}
}

Expand Down
Loading