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

Add 'type' label to workspace stop metric #5423

Merged
merged 1 commit into from
Aug 30, 2021
Merged
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
6 changes: 3 additions & 3 deletions components/ws-manager/pkg/manager/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func newMetrics(m *Manager) *metrics {
Subsystem: metricsWorkspaceSubsystem,
Name: "workspace_stops_total",
Help: "total number of workspaces stopped",
}, []string{"reason"}),
}, []string{"reason", "type"}),
totalOpenPortGauge: prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: metricsWorkspaceSubsystem,
Expand Down Expand Up @@ -144,6 +144,7 @@ func (m *metrics) OnWorkspaceStarted(tpe api.WorkspaceType) {

func (m *metrics) OnChange(status *api.WorkspaceStatus) {
var removeFromState bool
tpe := api.WorkspaceType_name[int32(status.Spec.Type)]
m.mu.Lock()
defer func() {
if removeFromState {
Expand All @@ -165,7 +166,6 @@ func (m *metrics) OnChange(status *api.WorkspaceStatus) {
}

t := status.Metadata.StartedAt.AsTime()
tpe := api.WorkspaceType_name[int32(status.Spec.Type)]
hist, err := m.startupTimeHistVec.GetMetricWithLabelValues(tpe)
if err != nil {
log.WithError(err).WithField("type", tpe).Warn("cannot get startup time histogram metric")
Expand All @@ -185,7 +185,7 @@ func (m *metrics) OnChange(status *api.WorkspaceStatus) {
reason = "regular-stop"
}

counter, err := m.totalStopsCounterVec.GetMetricWithLabelValues(reason)
counter, err := m.totalStopsCounterVec.GetMetricWithLabelValues(reason, tpe)
if err != nil {
log.WithError(err).WithField("reason", reason).Warn("cannot get counter for workspace stops metric")
return
Expand Down