Skip to content

Commit

Permalink
Add requestID to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
VOID404 committed Nov 25, 2024
1 parent 64130ea commit 99be309
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/controller/runtime/runtime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package runtime
import (
"context"
"fmt"

Check failure on line 21 in internal/controller/runtime/runtime_controller.go

View workflow job for this annotation

GitHub Actions / govuln

"fmt" imported and not used

Check failure on line 21 in internal/controller/runtime/runtime_controller.go

View workflow job for this annotation

GitHub Actions / unit-tests

"fmt" imported and not used

Check failure on line 21 in internal/controller/runtime/runtime_controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"fmt" imported and not used)

Check failure on line 21 in internal/controller/runtime/runtime_controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"fmt" imported and not used
"sync/atomic"

"github.com/go-logr/logr"
imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 99be309

Please sign in to comment.