@@ -60,21 +60,21 @@ func newMetrics(m *Manager) *metrics {
60
60
Help : "time it took for workspace pods to reach the running phase" ,
61
61
// same as components/ws-manager-bridge/src/prometheus-metrics-exporter.ts#L15
62
62
Buckets : prometheus .ExponentialBuckets (2 , 2 , 10 ),
63
- }, []string {"type" }),
63
+ }, []string {"type" , "class" }),
64
64
initializeTimeHistVec : prometheus .NewHistogramVec (prometheus.HistogramOpts {
65
65
Namespace : metricsNamespace ,
66
66
Subsystem : metricsWorkspaceSubsystem ,
67
67
Name : "workspace_initialize_seconds" ,
68
68
Help : "time it took to initialize workspace" ,
69
69
Buckets : prometheus .ExponentialBuckets (2 , 2 , 10 ),
70
- }, []string {"type" }),
70
+ }, []string {"type" , "class" }),
71
71
finalizeTimeHistVec : prometheus .NewHistogramVec (prometheus.HistogramOpts {
72
72
Namespace : metricsNamespace ,
73
73
Subsystem : metricsWorkspaceSubsystem ,
74
74
Name : "workspace_finalize_seconds" ,
75
75
Help : "time it took to finalize workspace" ,
76
76
Buckets : prometheus .ExponentialBuckets (2 , 2 , 10 ),
77
- }, []string {"type" }),
77
+ }, []string {"type" , "class" }),
78
78
volumeSnapshotTimeHistVec : prometheus .NewHistogramVec (prometheus.HistogramOpts {
79
79
Namespace : metricsNamespace ,
80
80
Subsystem : metricsWorkspaceSubsystem ,
@@ -87,13 +87,13 @@ func newMetrics(m *Manager) *metrics {
87
87
Subsystem : metricsWorkspaceSubsystem ,
88
88
Name : "workspace_starts_total" ,
89
89
Help : "total number of workspaces started" ,
90
- }, []string {"type" }),
90
+ }, []string {"type" , "class" }),
91
91
totalStopsCounterVec : prometheus .NewCounterVec (prometheus.CounterOpts {
92
92
Namespace : metricsNamespace ,
93
93
Subsystem : metricsWorkspaceSubsystem ,
94
94
Name : "workspace_stops_total" ,
95
95
Help : "total number of workspaces stopped" ,
96
- }, []string {"reason" , "type" }),
96
+ }, []string {"reason" , "type" , "class" }),
97
97
totalOpenPortGauge : prometheus .NewGaugeFunc (prometheus.GaugeOpts {
98
98
Namespace : metricsNamespace ,
99
99
Subsystem : metricsWorkspaceSubsystem ,
@@ -163,9 +163,9 @@ func (m *metrics) Register(reg prometheus.Registerer) error {
163
163
return nil
164
164
}
165
165
166
- func (m * metrics ) OnWorkspaceStarted (tpe api.WorkspaceType ) {
166
+ func (m * metrics ) OnWorkspaceStarted (tpe api.WorkspaceType , class string ) {
167
167
nme := api .WorkspaceType_name [int32 (tpe )]
168
- counter , err := m .totalStartsCounterVec .GetMetricWithLabelValues (nme )
168
+ counter , err := m .totalStartsCounterVec .GetMetricWithLabelValues (nme , class )
169
169
if err != nil {
170
170
log .WithError (err ).WithField ("type" , tpe ).Warn ("cannot get counter for workspace start metric" )
171
171
return
@@ -198,7 +198,7 @@ func (m *metrics) OnChange(status *api.WorkspaceStatus) {
198
198
}
199
199
200
200
t := status .Metadata .StartedAt .AsTime ()
201
- hist , err := m .startupTimeHistVec .GetMetricWithLabelValues (tpe )
201
+ hist , err := m .startupTimeHistVec .GetMetricWithLabelValues (tpe , status . Spec . Class )
202
202
if err != nil {
203
203
log .WithError (err ).WithField ("type" , tpe ).Warn ("cannot get startup time histogram metric" )
204
204
return
@@ -217,7 +217,7 @@ func (m *metrics) OnChange(status *api.WorkspaceStatus) {
217
217
reason = "regular-stop"
218
218
}
219
219
220
- counter , err := m .totalStopsCounterVec .GetMetricWithLabelValues (reason , tpe )
220
+ counter , err := m .totalStopsCounterVec .GetMetricWithLabelValues (reason , tpe , status . Spec . Class )
221
221
if err != nil {
222
222
log .WithError (err ).WithField ("reason" , reason ).Warn ("cannot get counter for workspace stops metric" )
223
223
return
@@ -240,7 +240,7 @@ func newPhaseTotalVec(m *Manager) *phaseTotalVec {
240
240
name := prometheus .BuildFQName (metricsNamespace , metricsWorkspaceSubsystem , "workspace_phase_total" )
241
241
return & phaseTotalVec {
242
242
name : name ,
243
- desc : prometheus .NewDesc (name , "Current number of workspaces per phase" , []string {"phase" , "type" }, prometheus .Labels (map [string ]string {})),
243
+ desc : prometheus .NewDesc (name , "Current number of workspaces per phase" , []string {"phase" , "type" , "class" }, prometheus .Labels (map [string ]string {})),
244
244
manager : m ,
245
245
}
246
246
}
@@ -276,16 +276,17 @@ func (m *phaseTotalVec) Collect(ch chan<- prometheus.Metric) {
276
276
}
277
277
status := api .WorkspacePhase_name [int32 (rawStatus .Phase )]
278
278
tpe := api .WorkspaceType_name [int32 (rawStatus .Spec .Type )]
279
+ class := rawStatus .Spec .Class
279
280
280
- counts [tpe + "::" + status ]++
281
+ counts [tpe + "::" + status + "::" + class ]++
281
282
}
282
283
283
284
for key , cnt := range counts {
284
285
segs := strings .Split (key , "::" )
285
- tpe , phase := segs [0 ], segs [1 ]
286
+ tpe , phase , class := segs [0 ], segs [1 ], segs [ 2 ]
286
287
287
288
// metrics cannot be re-used, we have to create them every single time
288
- metric , err := prometheus .NewConstMetric (m .desc , prometheus .GaugeValue , float64 (cnt ), phase , tpe )
289
+ metric , err := prometheus .NewConstMetric (m .desc , prometheus .GaugeValue , float64 (cnt ), phase , tpe , class )
289
290
if err != nil {
290
291
log .WithError (err ).Warnf ("cannot create workspace metric - %s will be inaccurate" , m .name )
291
292
continue
0 commit comments