From 99be309374a09760bf7704df0ee3d86e75a69f32 Mon Sep 17 00:00:00 2001 From: VOID404 Date: Mon, 25 Nov 2024 15:00:30 +0100 Subject: [PATCH] Add requestID to logs --- internal/controller/runtime/runtime_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/controller/runtime/runtime_controller.go b/internal/controller/runtime/runtime_controller.go index cbcd3a61..6f36f977 100644 --- a/internal/controller/runtime/runtime_controller.go +++ b/internal/controller/runtime/runtime_controller.go @@ -19,6 +19,7 @@ package runtime import ( "context" "fmt" + "sync/atomic" "github.com/go-logr/logr" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" @@ -39,6 +40,7 @@ type RuntimeReconciler struct { Log logr.Logger Cfg fsm.RCCfg EventRecorder record.EventRecorder + RequestID atomic.Uint64 } //+kubebuilder:rbac:groups=infrastructuremanager.kyma-project.io,resources=runtimes,verbs=get;list;watch;create;update;patch;delete @@ -67,11 +69,11 @@ func (r *RuntimeReconciler) Reconcile(ctx context.Context, request ctrl.Request) shootName = "N/D" } - log := r.Log.WithValues("runtimeID", runtimeID, "shootName", shootName) + log := r.Log.WithValues("runtimeID", runtimeID, "shootName", shootName, "requestID", r.RequestID.Add(1)) log.Info("Reconciling Runtime", "Name", runtime.Name, "Namespace", runtime.Namespace) stateFSM := fsm.NewFsm( - log.WithName(fmt.Sprintf("reqID %d", requCounter)), + log, r.Cfg, fsm.K8s{ Client: r.Client,