@@ -40,6 +40,7 @@ import (
40
40
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
41
41
expcontrollers "sigs.k8s.io/cluster-api-provider-gcp/exp/controllers"
42
42
"sigs.k8s.io/cluster-api-provider-gcp/feature"
43
+ ot "sigs.k8s.io/cluster-api-provider-gcp/pkg/otel"
43
44
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
44
45
"sigs.k8s.io/cluster-api-provider-gcp/version"
45
46
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
84
85
leaderElectionLeaseDuration time.Duration
85
86
leaderElectionRenewDeadline time.Duration
86
87
leaderElectionRetryPeriod time.Duration
88
+ enableTracing bool
87
89
)
88
90
89
91
func main () {
@@ -147,6 +149,13 @@ func main() {
147
149
// Setup the context that's going to be used in controllers and for the manager.
148
150
ctx := ctrl .SetupSignalHandler ()
149
151
152
+ if enableTracing {
153
+ if err := ot .RegisterTracing (ctx , setupLog ); err != nil {
154
+ setupLog .Error (err , "unable to set up tracing" )
155
+ os .Exit (1 )
156
+ }
157
+ }
158
+
150
159
if setupErr := setupReconcilers (ctx , mgr ); setupErr != nil {
151
160
setupLog .Error (err , "unable to setup reconcilers" )
152
161
os .Exit (1 )
@@ -366,5 +375,11 @@ func initFlags(fs *pflag.FlagSet) {
366
375
"The maximum duration a reconcile loop can run (e.g. 90m)" ,
367
376
)
368
377
378
+ fs .BoolVar (& enableTracing ,
379
+ "enable-tracing" ,
380
+ false ,
381
+ "Enable collecting and sending traces to opentelemetry-collector service" ,
382
+ )
383
+
369
384
feature .MutableGates .AddFlag (fs )
370
385
}
0 commit comments