Skip to content
Draft

debug #1610

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import (
"context"
"encoding/json"
"fmt"
"regexp"
"strings"

Expand All @@ -12,6 +14,7 @@
"k8s.io/apimachinery/pkg/api/meta"
kstatus "sigs.k8s.io/cli-utils/pkg/kstatus/status"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
k8smetrics "sigs.k8s.io/controller-runtime/pkg/metrics"

Expand Down Expand Up @@ -120,6 +123,7 @@
if err := k8smetrics.Registry.Register(c); err != nil {
return err
}
logf.FromContext(ctx).Info("ImageMetricsCollectorStart", "heisann", "hoppsann")

Check failure on line 126 in internal/metrics/collector.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing whitespace above this line (invalid statement above expr) (wsl_v5)

// Block until the context is done.
<-ctx.Done()
Expand Down Expand Up @@ -153,6 +157,8 @@
issuesLabelValues := make([]string, len(cisLabelValues)+1)
patchStatusLabelValues := make([]string, len(cisLabelValues)+1)

logf.FromContext(ctx).Info("ImageMetricsCollector", "len", fmt.Sprintf("%v", len(cisList.Items)))

for _, cis := range cisList.Items {
for i, l := range c.cisLabels {
cisLabelValues[i] = l.value(cis)
Expand Down Expand Up @@ -192,9 +198,12 @@
}
}

d, _ := json.Marshal(severities)
logf.FromContext(ctx).Info("IssuesSeverities", "issues", string(d))
for severity, count := range severities {

Check failure on line 203 in internal/metrics/collector.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing whitespace above this line (invalid statement above range) (wsl_v5)
issuesLabelValues[len(issuesLabelValues)-1] = severity
metrics <- prometheus.MustNewConstMetric(c.issuesDesc, prometheus.GaugeValue, float64(count), issuesLabelValues...)
logf.FromContext(ctx).Info("Issues", "issues", fmt.Sprintf("%v", count))

Check failure on line 206 in internal/metrics/collector.go

View workflow job for this annotation

GitHub Actions / golangci-lint

missing whitespace above this line (invalid statement above expr) (wsl_v5)
}

for patchStatus, count := range patchStatuses {
Expand Down
Loading