@@ -37,6 +37,7 @@ import (
37
37
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
38
38
expcontrollers "sigs.k8s.io/cluster-api-provider-gcp/exp/controllers"
39
39
"sigs.k8s.io/cluster-api-provider-gcp/feature"
40
+ ot "sigs.k8s.io/cluster-api-provider-gcp/pkg/otel"
40
41
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
41
42
"sigs.k8s.io/cluster-api-provider-gcp/version"
42
43
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
82
83
leaderElectionLeaseDuration time.Duration
83
84
leaderElectionRenewDeadline time.Duration
84
85
leaderElectionRetryPeriod time.Duration
86
+ enableTracing bool
85
87
)
86
88
87
89
// Add RBAC for the authorized diagnostics endpoint.
@@ -162,6 +164,13 @@ func main() {
162
164
// Setup the context that's going to be used in controllers and for the manager.
163
165
ctx := ctrl .SetupSignalHandler ()
164
166
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
+
165
174
if err := setupReconcilers (ctx , mgr ); err != nil {
166
175
setupLog .Error (err , "unable to setup reconcilers" )
167
176
os .Exit (1 )
@@ -374,6 +383,12 @@ func initFlags(fs *pflag.FlagSet) {
374
383
"The maximum duration a reconcile loop can run (e.g. 90m)" ,
375
384
)
376
385
386
+ fs .BoolVar (& enableTracing ,
387
+ "enable-tracing" ,
388
+ false ,
389
+ "Enable collecting and sending traces to opentelemetry-collector service" ,
390
+ )
391
+
377
392
flags .AddManagerOptions (fs , & managerOptions )
378
393
379
394
feature .MutableGates .AddFlag (fs )
0 commit comments