@@ -23,6 +23,7 @@ const (
23
23
Outcome = "outcome"
24
24
Succeeded = "succeeded"
25
25
Failed = "failed"
26
+ APPROVAL_LABEL = "approval"
26
27
)
27
28
28
29
type MetricsProvider interface {
@@ -153,7 +154,7 @@ var (
153
154
Name : "subscription_sync_total" ,
154
155
Help : "Monotonic count of subscription syncs" ,
155
156
},
156
- []string {NAME_LABEL , INSTALLED_LABEL , CHANNEL_LABEL , PACKAGE_LABEL },
157
+ []string {NAME_LABEL , INSTALLED_LABEL , CHANNEL_LABEL , PACKAGE_LABEL , APPROVAL_LABEL },
157
158
)
158
159
159
160
csvSucceeded = prometheus .NewGaugeVec (
@@ -188,9 +189,10 @@ var (
188
189
)
189
190
190
191
type subscriptionSyncLabelValues struct {
191
- installedCSV string
192
- pkg string
193
- channel string
192
+ installedCSV string
193
+ pkg string
194
+ channel string
195
+ approvalStrategy string
194
196
}
195
197
196
198
func RegisterOLM () {
@@ -208,8 +210,8 @@ func RegisterCatalog() {
208
210
prometheus .MustRegister (dependencyResolutionSummary )
209
211
}
210
212
211
- func CounterForSubscription (name , installedCSV , channelName , packageName string ) prometheus.Counter {
212
- return SubscriptionSyncCount .WithLabelValues (name , installedCSV , channelName , packageName )
213
+ func CounterForSubscription (name , installedCSV , channelName , packageName , planApprovalStrategy string ) prometheus.Counter {
214
+ return SubscriptionSyncCount .WithLabelValues (name , installedCSV , channelName , packageName , planApprovalStrategy )
213
215
}
214
216
215
217
func DeleteCSVMetric (oldCSV * olmv1alpha1.ClusterServiceVersion ) {
@@ -246,12 +248,13 @@ func EmitSubMetric(sub *olmv1alpha1.Subscription) {
246
248
if sub .Spec == nil {
247
249
return
248
250
}
249
- SubscriptionSyncCount .WithLabelValues (sub .GetName (), sub .Status .InstalledCSV , sub .Spec .Channel , sub .Spec .Package ).Inc ()
251
+ SubscriptionSyncCount .WithLabelValues (sub .GetName (), sub .Status .InstalledCSV , sub .Spec .Channel , sub .Spec .Package , string ( sub . Spec . InstallPlanApproval ) ).Inc ()
250
252
if _ , present := subscriptionSyncCounters [sub .GetName ()]; ! present {
251
253
subscriptionSyncCounters [sub .GetName ()] = subscriptionSyncLabelValues {
252
- installedCSV : sub .Status .InstalledCSV ,
253
- pkg : sub .Spec .Package ,
254
- channel : sub .Spec .Channel ,
254
+ installedCSV : sub .Status .InstalledCSV ,
255
+ pkg : sub .Spec .Package ,
256
+ channel : sub .Spec .Channel ,
257
+ approvalStrategy : string (sub .Spec .InstallPlanApproval ),
255
258
}
256
259
}
257
260
}
@@ -260,25 +263,28 @@ func DeleteSubsMetric(sub *olmv1alpha1.Subscription) {
260
263
if sub .Spec == nil {
261
264
return
262
265
}
263
- SubscriptionSyncCount .DeleteLabelValues (sub .GetName (), sub .Status .InstalledCSV , sub .Spec .Channel , sub .Spec .Package )
266
+ SubscriptionSyncCount .DeleteLabelValues (sub .GetName (), sub .Status .InstalledCSV , sub .Spec .Channel , sub .Spec .Package , string ( sub . Spec . InstallPlanApproval ) )
264
267
}
265
268
266
269
func UpdateSubsSyncCounterStorage (sub * olmv1alpha1.Subscription ) {
267
270
if sub .Spec == nil {
268
271
return
269
272
}
270
273
counterValues := subscriptionSyncCounters [sub .GetName ()]
274
+ approvalStrategy := string (sub .Spec .InstallPlanApproval )
271
275
272
276
if sub .Spec .Channel != counterValues .channel ||
273
277
sub .Spec .Package != counterValues .pkg ||
274
- sub .Status .InstalledCSV != counterValues .installedCSV {
278
+ sub .Status .InstalledCSV != counterValues .installedCSV ||
279
+ approvalStrategy != counterValues .approvalStrategy {
275
280
276
281
// Delete metric will label values of old Subscription first
277
- SubscriptionSyncCount .DeleteLabelValues (sub .GetName (), counterValues .installedCSV , counterValues .channel , counterValues .pkg )
282
+ SubscriptionSyncCount .DeleteLabelValues (sub .GetName (), counterValues .installedCSV , counterValues .channel , counterValues .pkg , counterValues . approvalStrategy )
278
283
279
284
counterValues .installedCSV = sub .Status .InstalledCSV
280
285
counterValues .pkg = sub .Spec .Package
281
286
counterValues .channel = sub .Spec .Channel
287
+ counterValues .approvalStrategy = approvalStrategy
282
288
283
289
subscriptionSyncCounters [sub .GetName ()] = counterValues
284
290
}
0 commit comments