Skip to content

Commit 6402c7d

Browse files
authored
Merge pull request #109 from fluxcd/metrics
Implement Prometheus instrumentation
2 parents fc783db + 1819f14 commit 6402c7d

File tree

6 files changed

+77
-28
lines changed

6 files changed

+77
-28
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.15
44

55
require (
66
github.com/fluxcd/pkg/apis/meta v0.0.2
7-
github.com/fluxcd/pkg/runtime v0.0.6
7+
github.com/fluxcd/pkg/runtime v0.1.0
88
k8s.io/api v0.18.9
99
k8s.io/apiextensions-apiserver v0.18.9
1010
k8s.io/apimachinery v0.18.9

api/go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
6363
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
6464
github.com/fluxcd/pkg/apis/meta v0.0.2 h1:kyA4Y0IzNjf1joBOnFqpWG7aNDHvtLExZcaHQM7qhRI=
6565
github.com/fluxcd/pkg/apis/meta v0.0.2/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
66-
github.com/fluxcd/pkg/runtime v0.0.6 h1:m7qwr2wRePs1vzVlM0Y88vitXSsv1lb3QCJflRpa3qQ=
67-
github.com/fluxcd/pkg/runtime v0.0.6/go.mod h1:iLjncjktQVpqpb1NsY2fW+UYDFOtVyt+yJrxqrrK8A0=
66+
github.com/fluxcd/pkg/runtime v0.1.0 h1:mCLj5GlQZqWtK3tvtZTmfgFOLsTUY1iqg3CmEyS1nRs=
67+
github.com/fluxcd/pkg/runtime v0.1.0/go.mod h1:OXkrYtDLw3GhclbzvnzfSktUyxRmC3FFhXj0tVVaIX8=
6868
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
6969
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
7070
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -165,6 +165,9 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb
165165
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
166166
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
167167
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
168+
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
169+
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
170+
github.com/hashicorp/go-retryablehttp v0.6.7/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
168171
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
169172
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
170173
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=

controllers/helmrelease_controller.go

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ import (
4545
"sigs.k8s.io/controller-runtime/pkg/controller"
4646

4747
"github.com/fluxcd/pkg/apis/meta"
48-
"github.com/fluxcd/pkg/recorder"
48+
"github.com/fluxcd/pkg/runtime/events"
49+
"github.com/fluxcd/pkg/runtime/metrics"
4950
"github.com/fluxcd/pkg/runtime/predicates"
5051
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
5152

@@ -62,7 +63,8 @@ type HelmReleaseReconciler struct {
6263
Scheme *runtime.Scheme
6364
requeueDependency time.Duration
6465
EventRecorder kuberecorder.EventRecorder
65-
ExternalEventRecorder *recorder.EventRecorder
66+
ExternalEventRecorder *events.Recorder
67+
MetricsRecorder *metrics.Recorder
6668
}
6769

6870
// ConditionError represents an error with a status condition reason attached.
@@ -107,17 +109,18 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
107109
if containsString(hr.ObjectMeta.Finalizers, v2.HelmReleaseFinalizer) {
108110
// Our finalizer is still present, so lets handle garbage collection
109111
if err := r.garbageCollect(ctx, log, hr); err != nil {
110-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityError, err.Error())
112+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityError, err.Error())
111113
// Return the error so we retry the failed garbage collection
112114
return ctrl.Result{}, err
113115
}
114-
116+
// Record deleted status
117+
r.recordReadiness(hr, true)
115118
// Remove our finalizer from the list and update it
116119
hr.ObjectMeta.Finalizers = removeString(hr.ObjectMeta.Finalizers, v2.HelmReleaseFinalizer)
117120
if err := r.Update(ctx, &hr); err != nil {
118121
return ctrl.Result{}, err
119122
}
120-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityInfo, "Helm uninstall for deleted resource succeeded")
123+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityInfo, "Helm uninstall for deleted resource succeeded")
121124
}
122125
// Stop reconciliation as the object is being deleted
123126
return ctrl.Result{}, nil
@@ -131,6 +134,9 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
131134
return ctrl.Result{Requeue: true}, updateStatusErr
132135
}
133136

137+
// Record ready status
138+
r.recordReadiness(hr, false)
139+
134140
// Log reconciliation duration
135141
durationMsg := fmt.Sprintf("reconcilation finished in %s", time.Now().Sub(start).String())
136142
if result.RequeueAfter > 0 {
@@ -142,6 +148,7 @@ func (r *HelmReleaseReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
142148
}
143149

144150
func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger, hr v2.HelmRelease) (v2.HelmRelease, ctrl.Result, error) {
151+
reconcileStart := time.Now()
145152
// Record the value of the reconciliation request, if any
146153
if v, ok := hr.GetAnnotations()[meta.ReconcileAtAnnotation]; ok {
147154
hr.Status.LastHandledReconcileAt = v
@@ -155,6 +162,8 @@ func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger,
155162
log.Error(updateStatusErr, "unable to update status after generation update")
156163
return hr, ctrl.Result{Requeue: true}, updateStatusErr
157164
}
165+
// Record progressing status
166+
r.recordReadiness(hr, false)
158167
}
159168

160169
if hr.Spec.Suspend {
@@ -163,24 +172,33 @@ func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger,
163172
return v2.HelmReleaseNotReady(hr, meta.SuspendedReason, msg), ctrl.Result{}, nil
164173
}
165174

175+
// record reconciliation duration
176+
if r.MetricsRecorder != nil {
177+
objRef, err := reference.GetReference(r.Scheme, &hr)
178+
if err != nil {
179+
return hr, ctrl.Result{Requeue: true}, err
180+
}
181+
defer r.MetricsRecorder.RecordDuration(*objRef, reconcileStart)
182+
}
183+
166184
// Reconcile chart based on the HelmChartTemplate
167185
hc, ok, reconcileErr := r.reconcileChart(ctx, &hr)
168186
if !ok {
169187
var msg string
170188
if reconcileErr != nil {
171189
msg = fmt.Sprintf("chart reconciliation failed: %s", reconcileErr.Error())
172-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityError, msg)
190+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityError, msg)
173191
} else {
174192
msg = "HelmChart is not ready"
175-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityInfo, msg)
193+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityInfo, msg)
176194
}
177195
return v2.HelmReleaseNotReady(hr, v2.ArtifactFailedReason, msg), ctrl.Result{}, reconcileErr
178196
}
179197

180198
// Check chart artifact readiness
181199
if hc.GetArtifact() == nil {
182200
msg := "HelmChart is not ready"
183-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityInfo, msg)
201+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityInfo, msg)
184202
log.Info(msg)
185203
return v2.HelmReleaseNotReady(hr, v2.ArtifactFailedReason, msg), ctrl.Result{}, nil
186204
}
@@ -190,7 +208,7 @@ func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger,
190208
if err := r.checkDependencies(hr); err != nil {
191209
msg := fmt.Sprintf("dependencies do not meet ready condition (%s), retrying in %s",
192210
err.Error(), r.requeueDependency.String())
193-
r.event(hr, hc.GetArtifact().Revision, recorder.EventSeverityInfo, msg)
211+
r.event(hr, hc.GetArtifact().Revision, events.EventSeverityInfo, msg)
194212
log.Info(msg)
195213

196214
// Exponential backoff would cause execution to be prolonged too much,
@@ -204,21 +222,21 @@ func (r *HelmReleaseReconciler) reconcile(ctx context.Context, log logr.Logger,
204222
// Compose values
205223
values, err := r.composeValues(ctx, hr)
206224
if err != nil {
207-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityError, err.Error())
225+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityError, err.Error())
208226
return v2.HelmReleaseNotReady(hr, v2.InitFailedReason, err.Error()), ctrl.Result{}, nil
209227
}
210228

211229
// Load chart from artifact
212230
chart, err := r.loadHelmChart(hc)
213231
if err != nil {
214-
r.event(hr, hr.Status.LastAttemptedRevision, recorder.EventSeverityError, err.Error())
232+
r.event(hr, hr.Status.LastAttemptedRevision, events.EventSeverityError, err.Error())
215233
return v2.HelmReleaseNotReady(hr, v2.ArtifactFailedReason, err.Error()), ctrl.Result{}, nil
216234
}
217235

218236
// Reconcile Helm release
219237
reconciledHr, reconcileErr := r.reconcileRelease(ctx, log, *hr.DeepCopy(), chart, values)
220238
if reconcileErr != nil {
221-
r.event(hr, hc.GetArtifact().Revision, recorder.EventSeverityError,
239+
r.event(hr, hc.GetArtifact().Revision, events.EventSeverityError,
222240
fmt.Sprintf("reconciliation failed: %s", reconcileErr.Error()))
223241
}
224242
return reconciledHr, ctrl.Result{RequeueAfter: hr.Spec.Interval.Duration}, reconcileErr
@@ -303,6 +321,8 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, log logr.L
303321
log.Error(updateStatusErr, "unable to update status after state update")
304322
return hr, updateStatusErr
305323
}
324+
// Record progressing status
325+
r.recordReadiness(hr, false)
306326
}
307327

308328
// Check status of any previous release attempt.
@@ -629,12 +649,12 @@ func (r *HelmReleaseReconciler) handleHelmActionResult(hr *v2.HelmRelease, revis
629649
if err != nil {
630650
msg := fmt.Sprintf("Helm %s failed: %s", action, err.Error())
631651
v2.SetHelmReleaseCondition(hr, condition, corev1.ConditionFalse, failedReason, msg)
632-
r.event(*hr, revision, recorder.EventSeverityError, msg)
652+
r.event(*hr, revision, events.EventSeverityError, msg)
633653
return &ConditionError{Reason: failedReason, Err: errors.New(msg)}
634654
} else {
635655
msg := fmt.Sprintf("Helm %s succeeded", action)
636656
v2.SetHelmReleaseCondition(hr, condition, corev1.ConditionTrue, succeededReason, msg)
637-
r.event(*hr, revision, recorder.EventSeverityInfo, msg)
657+
r.event(*hr, revision, events.EventSeverityInfo, msg)
638658
return nil
639659
}
640660
}
@@ -666,6 +686,29 @@ func (r *HelmReleaseReconciler) event(hr v2.HelmRelease, revision, severity, msg
666686
}
667687
}
668688

689+
func (r *HelmReleaseReconciler) recordReadiness(hr v2.HelmRelease, deleted bool) {
690+
if r.MetricsRecorder == nil {
691+
return
692+
}
693+
694+
objRef, err := reference.GetReference(r.Scheme, &hr)
695+
if err != nil {
696+
r.Log.WithValues(
697+
strings.ToLower(hr.Kind),
698+
fmt.Sprintf("%s/%s", hr.GetNamespace(), hr.GetName()),
699+
).Error(err, "unable to record readiness metric")
700+
return
701+
}
702+
if rc := meta.GetCondition(hr.Status.Conditions, meta.ReadyCondition); rc != nil {
703+
r.MetricsRecorder.RecordCondition(*objRef, *rc, deleted)
704+
} else {
705+
r.MetricsRecorder.RecordCondition(*objRef, meta.Condition{
706+
Type: meta.ReadyCondition,
707+
Status: corev1.ConditionUnknown,
708+
}, deleted)
709+
}
710+
}
711+
669712
func helmChartFromTemplate(hr v2.HelmRelease) *sourcev1.HelmChart {
670713
template := hr.Spec.Chart
671714
return &sourcev1.HelmChart{

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ replace github.com/fluxcd/helm-controller/api => ./api
77
require (
88
github.com/fluxcd/helm-controller/api v0.1.0
99
github.com/fluxcd/pkg/apis/meta v0.0.2
10-
github.com/fluxcd/pkg/recorder v0.0.5
11-
github.com/fluxcd/pkg/runtime v0.0.6
10+
github.com/fluxcd/pkg/runtime v0.1.0
1211
github.com/fluxcd/source-controller/api v0.1.0
1312
github.com/go-logr/logr v0.1.0
1413
github.com/onsi/ginkgo v1.12.1

go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
194194
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
195195
github.com/fluxcd/pkg/apis/meta v0.0.2 h1:kyA4Y0IzNjf1joBOnFqpWG7aNDHvtLExZcaHQM7qhRI=
196196
github.com/fluxcd/pkg/apis/meta v0.0.2/go.mod h1:nCNps5JJOcEQr3MNDmZqI4o0chjePSUYL6Q2ktDtotU=
197-
github.com/fluxcd/pkg/recorder v0.0.5 h1:D8qfupahIvh6ncCMn2yTHsrzG91S05sp4zdpsbKWeaU=
198-
github.com/fluxcd/pkg/recorder v0.0.5/go.mod h1:2UG6EroZ6ZbqmqoL8k/cQMe09e6A36WyH4t4UDUGyuU=
199197
github.com/fluxcd/pkg/runtime v0.0.6 h1:m7qwr2wRePs1vzVlM0Y88vitXSsv1lb3QCJflRpa3qQ=
200198
github.com/fluxcd/pkg/runtime v0.0.6/go.mod h1:iLjncjktQVpqpb1NsY2fW+UYDFOtVyt+yJrxqrrK8A0=
199+
github.com/fluxcd/pkg/runtime v0.1.0 h1:mCLj5GlQZqWtK3tvtZTmfgFOLsTUY1iqg3CmEyS1nRs=
200+
github.com/fluxcd/pkg/runtime v0.1.0/go.mod h1:OXkrYtDLw3GhclbzvnzfSktUyxRmC3FFhXj0tVVaIX8=
201201
github.com/fluxcd/source-controller/api v0.1.0 h1:ky3gMs3mnkDl6ClX+7uT2BNxU+sLzW/6a8B/M1KfySw=
202202
github.com/fluxcd/source-controller/api v0.1.0/go.mod h1:1ac/vj49YVPKF+xBHTo/9pfFj64TcLc1RLaxi4MwVEM=
203203
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
@@ -372,8 +372,8 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh
372372
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
373373
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
374374
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
375-
github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM=
376-
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
375+
github.com/hashicorp/go-retryablehttp v0.6.7 h1:8/CAEZt/+F7kR7GevNHulKkUjLht3CPmn7egmhieNKo=
376+
github.com/hashicorp/go-retryablehttp v0.6.7/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
377377
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
378378
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
379379
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
@@ -928,7 +928,6 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
928928
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
929929
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
930930
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
931-
k8s.io/api v0.18.4/go.mod h1:lOIQAKYgai1+vz9J7YcDZwC26Z0zQewYOGWdyIPUUQ4=
932931
k8s.io/api v0.18.6/go.mod h1:eeyxr+cwCjMdLAmr2W3RyDI0VvTawSg/3RFFBEnmZGI=
933932
k8s.io/api v0.18.8 h1:aIKUzJPb96f3fKec2lxtY7acZC9gQNDLVhfSGpxBAC4=
934933
k8s.io/api v0.18.8/go.mod h1:d/CXqwWv+Z2XEG1LgceeDmHQwpUJhROPx16SlxJgERY=
@@ -939,7 +938,6 @@ k8s.io/apiextensions-apiserver v0.18.8 h1:pkqYPKTHa0/3lYwH7201RpF9eFm0lmZDFBNzhN
939938
k8s.io/apiextensions-apiserver v0.18.8/go.mod h1:7f4ySEkkvifIr4+BRrRWriKKIJjPyg9mb/p63dJKnlM=
940939
k8s.io/apiextensions-apiserver v0.18.9 h1:tVEf8rVKh5BnXORnYYCztjbf6CSyGNMt/rAIEyfU00Q=
941940
k8s.io/apiextensions-apiserver v0.18.9/go.mod h1:JagmAhU0TVENzgUZqHJsjCSDh7YuV5o6g01G1Fwh7zI=
942-
k8s.io/apimachinery v0.18.4/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
943941
k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
944942
k8s.io/apimachinery v0.18.8 h1:jimPrycCqgx2QPearX3to1JePz7wSbVLq+7PdBTTwQ0=
945943
k8s.io/apimachinery v0.18.8/go.mod h1:6sQd+iHEqmOtALqOFjSWp2KZ9F0wlU/nWm0ZgsYWMig=

main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ import (
2929
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
3030
ctrl "sigs.k8s.io/controller-runtime"
3131
"sigs.k8s.io/controller-runtime/pkg/log/zap"
32+
crtlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
3233

33-
"github.com/fluxcd/pkg/recorder"
34+
"github.com/fluxcd/pkg/runtime/events"
35+
"github.com/fluxcd/pkg/runtime/metrics"
3436
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
3537

3638
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
@@ -78,16 +80,19 @@ func main() {
7880

7981
ctrl.SetLogger(newLogger(logLevel, logJSON))
8082

81-
var eventRecorder *recorder.EventRecorder
83+
var eventRecorder *events.Recorder
8284
if eventsAddr != "" {
83-
if er, err := recorder.NewEventRecorder(eventsAddr, "helm-controller"); err != nil {
85+
if er, err := events.NewRecorder(eventsAddr, "helm-controller"); err != nil {
8486
setupLog.Error(err, "unable to create event recorder")
8587
os.Exit(1)
8688
} else {
8789
eventRecorder = er
8890
}
8991
}
9092

93+
metricsRecorder := metrics.NewRecorder()
94+
crtlmetrics.Registry.MustRegister(metricsRecorder.Collectors()...)
95+
9196
watchNamespace := ""
9297
if !watchAllNamespaces {
9398
watchNamespace = os.Getenv("RUNTIME_NAMESPACE")
@@ -122,6 +127,7 @@ func main() {
122127
Scheme: mgr.GetScheme(),
123128
EventRecorder: mgr.GetEventRecorderFor("helm-controller"),
124129
ExternalEventRecorder: eventRecorder,
130+
MetricsRecorder: metricsRecorder,
125131
}).SetupWithManager(mgr, controllers.HelmReleaseReconcilerOptions{
126132
MaxConcurrentReconciles: concurrent,
127133
DependencyRequeueInterval: requeueDependency,

0 commit comments

Comments
 (0)