Skip to content

Commit f899af8

Browse files
meobilivangrichardcase
authored andcommitted
add enableTracing flag
1 parent d48f8bf commit f899af8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
3838
expcontrollers "sigs.k8s.io/cluster-api-provider-gcp/exp/controllers"
3939
"sigs.k8s.io/cluster-api-provider-gcp/feature"
40+
ot "sigs.k8s.io/cluster-api-provider-gcp/pkg/otel"
4041
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
4142
"sigs.k8s.io/cluster-api-provider-gcp/version"
4243
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -82,6 +83,7 @@ var (
8283
leaderElectionLeaseDuration time.Duration
8384
leaderElectionRenewDeadline time.Duration
8485
leaderElectionRetryPeriod time.Duration
86+
enableTracing bool
8587
)
8688

8789
// Add RBAC for the authorized diagnostics endpoint.
@@ -162,6 +164,13 @@ func main() {
162164
// Setup the context that's going to be used in controllers and for the manager.
163165
ctx := ctrl.SetupSignalHandler()
164166

167+
if enableTracing {
168+
if err := ot.RegisterTracing(ctx, setupLog); err != nil {
169+
setupLog.Error(err, "unable to set up tracing")
170+
os.Exit(1)
171+
}
172+
}
173+
165174
if err := setupReconcilers(ctx, mgr); err != nil {
166175
setupLog.Error(err, "unable to setup reconcilers")
167176
os.Exit(1)
@@ -374,6 +383,12 @@ func initFlags(fs *pflag.FlagSet) {
374383
"The maximum duration a reconcile loop can run (e.g. 90m)",
375384
)
376385

386+
fs.BoolVar(&enableTracing,
387+
"enable-tracing",
388+
false,
389+
"Enable collecting and sending traces to opentelemetry-collector service",
390+
)
391+
377392
flags.AddManagerOptions(fs, &managerOptions)
378393

379394
feature.MutableGates.AddFlag(fs)

0 commit comments

Comments
 (0)