Skip to content

Commit ed22853

Browse files
committed
make some improvements in logging and metrics
1 parent fd6856d commit ed22853

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

chart/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: flux-webhook-autoreconciler
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: "0.0.7"
6-
appVersion: "v0.0.7"
5+
version: "0.0.8"
6+
appVersion: "v0.0.8"

cmd/handlers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func (s *Handlers) Subscribe(w http.ResponseWriter, r *http.Request) {
161161
func (s *Handlers) HandleContainerPushPayload(payload ContainerPushPayload) {
162162
tag := payload.RegistryPackage.PackageVersion.ContainerMetadata.Tag.Name
163163
ociUrl := fmt.Sprintf("oci://ghcr.io/%s/%s", payload.RegistryPackage.Namespace, payload.RegistryPackage.Name)
164+
s.logger.Info("Handling container push payload", zap.String("ociUrl", ociUrl), zap.String("tag", tag))
164165

165166
for subscr := range s.subscribers {
166167
payload := SubscribeEventPayload{OciUrl: ociUrl, Tag: tag}

cmd/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
reconciledCount = prometheus.NewCounterVec(prometheus.CounterOpts{
2121
Name: fmt.Sprintf("%s_reconciliations_total", metricsNamespace),
2222
Help: "The total number of reconciliations",
23-
}, []string{"source", "status"})
23+
}, []string{"name", "status", "namespace"})
2424

2525
processedMessages = prometheus.NewCounterVec(prometheus.CounterOpts{
2626
Name: fmt.Sprintf("%s_processed_messages_total", metricsNamespace),

cmd/reconciler.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ func (r *Reconciler) ReconcileSources(ociUrl string, tag string) {
3232
}
3333
for _, ociRepository := range res.Items {
3434
if ociRepository.Spec.URL == ociUrl && ociRepository.Spec.Reference.Tag == tag {
35-
r.logger.Info("Reconciling OCIRepository", zap.String("name", ociRepository.Name))
35+
r.logger.Info("Reconciling OCIRepository", zap.String("name", ociRepository.Name), zap.String("namespace", ociRepository.Namespace))
3636
err := r.annotateRepository(ociRepository)
3737
if err != nil {
3838
r.logger.Error("Failed to annotate OCIRepository", zap.Error(err))
39-
reconciledCount.With(prometheus.Labels{"source": ociRepository.Name, "status": "fail"}).Inc()
39+
reconciledCount.With(prometheus.Labels{"name": ociRepository.Name, "status": "fail", "namespace": ociRepository.Namespace}).Inc()
4040
}
41-
reconciledCount.With(prometheus.Labels{"source": ociRepository.Name, "status": "success"}).Inc()
41+
reconciledCount.With(prometheus.Labels{"name": ociRepository.Name, "status": "success", "namespace": ociRepository.Namespace}).Inc()
4242
}
4343
}
4444
}
@@ -65,5 +65,4 @@ func (r *Reconciler) annotateRepository(repository sourceController.OCIRepositor
6565
Body(patchJson).
6666
Do(context.Background()).
6767
Into(&res)
68-
6968
}

0 commit comments

Comments
 (0)