Skip to content

Commit 347af9b

Browse files
jentingroboquat
authored andcommitted
Add label to differentiate backup/restore total/failure is PVC or GCS
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 20e91af commit 347af9b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

components/ws-manager/pkg/manager/metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,25 @@ func newMetrics(m *Manager) *metrics {
117117
Subsystem: metricsWorkspaceSubsystem,
118118
Name: "workspace_backups_total",
119119
Help: "total number of workspace backups",
120-
}, []string{"type", "class"}),
120+
}, []string{"type", "pvc", "class"}),
121121
totalBackupFailureCounterVec: prometheus.NewCounterVec(prometheus.CounterOpts{
122122
Namespace: metricsNamespace,
123123
Subsystem: metricsWorkspaceSubsystem,
124124
Name: "workspace_backups_failure_total",
125125
Help: "total number of workspace backup failures",
126-
}, []string{"type", "class"}),
126+
}, []string{"type", "pvc", "class"}),
127127
totalRestoreCounterVec: prometheus.NewCounterVec(prometheus.CounterOpts{
128128
Namespace: metricsNamespace,
129129
Subsystem: metricsWorkspaceSubsystem,
130130
Name: "workspace_restores_total",
131131
Help: "total number of workspace restores",
132-
}, []string{"type", "class"}),
132+
}, []string{"type", "pvc", "class"}),
133133
totalRestoreFailureCounterVec: prometheus.NewCounterVec(prometheus.CounterOpts{
134134
Namespace: metricsNamespace,
135135
Subsystem: metricsWorkspaceSubsystem,
136136
Name: "workspace_restores_failure_total",
137137
Help: "total number of workspace restore failures",
138-
}, []string{"type", "class"}),
138+
}, []string{"type", "pvc", "class"}),
139139
totalUnintentionalWorkspaceStopCounterVec: prometheus.NewCounterVec(prometheus.CounterOpts{
140140
Namespace: metricsNamespace,
141141
Subsystem: metricsWorkspaceSubsystem,

components/ws-manager/pkg/manager/monitor.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"net/url"
1313
"os"
14+
"strconv"
1415
"strings"
1516
"sync"
1617
"time"
@@ -903,9 +904,9 @@ func (m *Monitor) initializeWorkspaceContent(ctx context.Context, pod *corev1.Po
903904
_, isBackup := initializer.Spec.(*csapi.WorkspaceInitializer_Backup)
904905

905906
if isBackup {
906-
m.manager.metrics.totalRestoreCounterVec.WithLabelValues(wsType, wsClass).Inc()
907+
m.manager.metrics.totalRestoreCounterVec.WithLabelValues(wsType, strconv.FormatBool(pvcFeatureEnabled), wsClass).Inc()
907908
if err != nil {
908-
m.manager.metrics.totalRestoreFailureCounterVec.WithLabelValues(wsType, wsClass).Inc()
909+
m.manager.metrics.totalRestoreFailureCounterVec.WithLabelValues(wsType, strconv.FormatBool(pvcFeatureEnabled), wsClass).Inc()
909910
}
910911
}
911912

@@ -1301,11 +1302,11 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
13011302
}
13021303

13031304
if doBackup || doSnapshot {
1304-
m.manager.metrics.totalBackupCounterVec.WithLabelValues(wsType, wso.Pod.Labels[workspaceClassLabel]).Inc()
1305+
m.manager.metrics.totalBackupCounterVec.WithLabelValues(wsType, strconv.FormatBool(pvcFeatureEnabled), wso.Pod.Labels[workspaceClassLabel]).Inc()
13051306
}
13061307

13071308
if backupError != nil {
1308-
m.manager.metrics.totalBackupFailureCounterVec.WithLabelValues(wsType, wso.Pod.Labels[workspaceClassLabel]).Inc()
1309+
m.manager.metrics.totalBackupFailureCounterVec.WithLabelValues(wsType, strconv.FormatBool(pvcFeatureEnabled), wso.Pod.Labels[workspaceClassLabel]).Inc()
13091310

13101311
if dataloss {
13111312
disposalStatus.BackupFailure = backupError.Error()

0 commit comments

Comments
 (0)