Skip to content

Commit 8a80af2

Browse files
committed
debug: log
1 parent 11fed91 commit 8a80af2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/metrics/collector.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package metrics
22

33
import (
44
"context"
5+
"encoding/json"
6+
"fmt"
57
"regexp"
68
"strings"
79

@@ -12,6 +14,7 @@ import (
1214
"k8s.io/apimachinery/pkg/api/meta"
1315
kstatus "sigs.k8s.io/cli-utils/pkg/kstatus/status"
1416
"sigs.k8s.io/controller-runtime/pkg/client"
17+
logf "sigs.k8s.io/controller-runtime/pkg/log"
1518
"sigs.k8s.io/controller-runtime/pkg/manager"
1619
k8smetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
1720

@@ -120,6 +123,7 @@ func (c ImageMetricsCollector) Start(ctx context.Context) error {
120123
if err := k8smetrics.Registry.Register(c); err != nil {
121124
return err
122125
}
126+
logf.FromContext(ctx).Info("ImageMetricsCollectorStart", "heisann", "hoppsann")
123127

124128
// Block until the context is done.
125129
<-ctx.Done()
@@ -153,6 +157,8 @@ func (c ImageMetricsCollector) Collect(metrics chan<- prometheus.Metric) {
153157
issuesLabelValues := make([]string, len(cisLabelValues)+1)
154158
patchStatusLabelValues := make([]string, len(cisLabelValues)+1)
155159

160+
logf.FromContext(ctx).Info("ImageMetricsCollector", "len", string(len(cisList.Items)))
161+
156162
for _, cis := range cisList.Items {
157163
for i, l := range c.cisLabels {
158164
cisLabelValues[i] = l.value(cis)
@@ -192,9 +198,12 @@ func (c ImageMetricsCollector) Collect(metrics chan<- prometheus.Metric) {
192198
}
193199
}
194200

201+
d, _ := json.Marshal(severities)
202+
logf.FromContext(ctx).Info("IssuesSeverities", "issues", string(d))
195203
for severity, count := range severities {
196204
issuesLabelValues[len(issuesLabelValues)-1] = severity
197205
metrics <- prometheus.MustNewConstMetric(c.issuesDesc, prometheus.GaugeValue, float64(count), issuesLabelValues...)
206+
logf.FromContext(ctx).Info("Issues", "issues", fmt.Sprintf("%v", count))
198207
}
199208

200209
for patchStatus, count := range patchStatuses {

0 commit comments

Comments
 (0)