Skip to content

Commit

Permalink
chore: making changes to the defer function
Browse files Browse the repository at this point in the history
  • Loading branch information
bhussain91 committed May 17, 2024
1 parent 1eb19da commit f64c6dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ deploy: manifests kustomize ## Deploy to the K8s cluster specified in ~/.kube/co
$(KUSTOMIZE) build config/default | kubectl apply -f -

undeploy:
$(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build config/default | kubectl delete -f -
26 changes: 15 additions & 11 deletions interceptor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,7 @@ func main() {

eg, ctx := errgroup.WithContext(ctx)

if tracingCfg.Enabled {
shutdown, err := tracing.SetupOTelSDK(ctx, tracingCfg)

if err != nil {
setupLog.Error(err, "Error setting up tracer")
}

defer func() {
err = errors.Join(err, shutdown(context.Background()))
}()
}
configureTracing(ctx, tracingCfg)

// start the endpoints cache updater
eg.Go(func() error {
Expand Down Expand Up @@ -218,6 +208,20 @@ func main() {
setupLog.Info("Bye!")
}

func configureTracing(ctx context.Context, tracingCfg *config.Tracing) {
if tracingCfg.Enabled {
shutdown, err := tracing.SetupOTelSDK(ctx, tracingCfg)

if err != nil {
setupLog.Error(err, "Error setting up tracer")
}

defer func() {
err = errors.Join(err, shutdown(context.Background()))
}()
}
}

func runAdminServer(
ctx context.Context,
lggr logr.Logger,
Expand Down

0 comments on commit f64c6dc

Please sign in to comment.