Skip to content

Commit 4ef8d23

Browse files
committed
chore: enhance metric labels implementation
Original work by @Suraiya-Hameed in #1433
1 parent 3bc8225 commit 4ef8d23

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

controllers/stats_reporter.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,12 @@ func newStatsReporter() (StatsReporter, error) {
6565
func (r reporter) ReportSyncSecretCtMetric(ctx context.Context, provider, namespace, spc string) {
6666
opt := metric.WithAttributes(
6767
attribute.Key(providerKey).String(provider),
68-
attribute.Key(osTypeKey).String(runtimeOS),
6968
attribute.Key(namespaceKey).String(namespace),
7069
attribute.Key(spcKey).String(spc),
7170
)
7271
r.syncK8sSecretTotal.Add(ctx, 1, opt)
7372
}
7473

7574
func (r reporter) ReportSyncSecretDuration(ctx context.Context, duration float64) {
76-
opt := metric.WithAttributes(
77-
attribute.Key(osTypeKey).String(runtimeOS),
78-
)
79-
r.syncK8sSecretDuration.Record(ctx, duration, opt)
75+
r.syncK8sSecretDuration.Record(ctx, duration)
8076
}

pkg/rotation/reconciler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
253253
var providerName string
254254
podName := spcps.Status.PodName
255255
podNamespace := spcps.Namespace
256-
secretProviderClass := spcps.Status.SecretProviderClassName
256+
secretProviderClassName := spcps.Status.SecretProviderClassName
257257

258258
defer func() {
259259
if err != nil {
260-
r.reporter.reportRotationErrorCtMetric(ctx, providerName, podName, podNamespace, secretProviderClass, errorReason, requiresUpdate)
260+
r.reporter.reportRotationErrorCtMetric(ctx, providerName, podName, podNamespace, secretProviderClassName, errorReason, requiresUpdate)
261261
return
262262
}
263-
r.reporter.reportRotationCtMetric(ctx, providerName, podName, podNamespace, secretProviderClass, requiresUpdate)
263+
r.reporter.reportRotationCtMetric(ctx, providerName, podName, podNamespace, secretProviderClassName, requiresUpdate)
264264
r.reporter.reportRotationDuration(ctx, time.Since(begin).Seconds())
265265
}()
266266

@@ -293,13 +293,13 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
293293
ctx,
294294
client.ObjectKey{
295295
Namespace: podNamespace,
296-
Name: secretProviderClass,
296+
Name: secretProviderClassName,
297297
},
298298
spc,
299299
)
300300
if err != nil {
301301
errorReason = internalerrors.SecretProviderClassNotFound
302-
return fmt.Errorf("failed to get secret provider class %s/%s, err: %w", podNamespace, secretProviderClass, err)
302+
return fmt.Errorf("failed to get secret provider class %s/%s, err: %w", podNamespace, secretProviderClassName, err)
303303
}
304304

305305
// determine which pod volume this is associated with

0 commit comments

Comments
 (0)