Skip to content

Commit

Permalink
make some improvements in logging and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nikmel2803 committed Sep 26, 2023
1 parent fd6856d commit ed22853
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: flux-webhook-autoreconciler
description: A Helm chart for Kubernetes
type: application
version: "0.0.7"
appVersion: "v0.0.7"
version: "0.0.8"
appVersion: "v0.0.8"
1 change: 1 addition & 0 deletions cmd/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (s *Handlers) Subscribe(w http.ResponseWriter, r *http.Request) {
func (s *Handlers) HandleContainerPushPayload(payload ContainerPushPayload) {
tag := payload.RegistryPackage.PackageVersion.ContainerMetadata.Tag.Name
ociUrl := fmt.Sprintf("oci://ghcr.io/%s/%s", payload.RegistryPackage.Namespace, payload.RegistryPackage.Name)
s.logger.Info("Handling container push payload", zap.String("ociUrl", ociUrl), zap.String("tag", tag))

for subscr := range s.subscribers {
payload := SubscribeEventPayload{OciUrl: ociUrl, Tag: tag}
Expand Down
2 changes: 1 addition & 1 deletion cmd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
reconciledCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_reconciliations_total", metricsNamespace),
Help: "The total number of reconciliations",
}, []string{"source", "status"})
}, []string{"name", "status", "namespace"})

processedMessages = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_processed_messages_total", metricsNamespace),
Expand Down
7 changes: 3 additions & 4 deletions cmd/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func (r *Reconciler) ReconcileSources(ociUrl string, tag string) {
}
for _, ociRepository := range res.Items {
if ociRepository.Spec.URL == ociUrl && ociRepository.Spec.Reference.Tag == tag {
r.logger.Info("Reconciling OCIRepository", zap.String("name", ociRepository.Name))
r.logger.Info("Reconciling OCIRepository", zap.String("name", ociRepository.Name), zap.String("namespace", ociRepository.Namespace))
err := r.annotateRepository(ociRepository)
if err != nil {
r.logger.Error("Failed to annotate OCIRepository", zap.Error(err))
reconciledCount.With(prometheus.Labels{"source": ociRepository.Name, "status": "fail"}).Inc()
reconciledCount.With(prometheus.Labels{"name": ociRepository.Name, "status": "fail", "namespace": ociRepository.Namespace}).Inc()
}
reconciledCount.With(prometheus.Labels{"source": ociRepository.Name, "status": "success"}).Inc()
reconciledCount.With(prometheus.Labels{"name": ociRepository.Name, "status": "success", "namespace": ociRepository.Namespace}).Inc()
}
}
}
Expand All @@ -65,5 +65,4 @@ func (r *Reconciler) annotateRepository(repository sourceController.OCIRepositor
Body(patchJson).
Do(context.Background()).
Into(&res)

}

0 comments on commit ed22853

Please sign in to comment.