@@ -23,6 +23,8 @@ import (
23
23
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter"
24
24
"github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
25
25
"github.com/pkg/errors"
26
+ "go.opentelemetry.io/otel/attribute"
27
+ "go.opentelemetry.io/otel/trace"
26
28
apierrors "k8s.io/apimachinery/pkg/api/errors"
27
29
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
28
30
"sigs.k8s.io/cluster-api-provider-gcp/cloud"
@@ -32,6 +34,7 @@ import (
32
34
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/networks"
33
35
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/subnets"
34
36
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
37
+ "sigs.k8s.io/cluster-api-provider-gcp/util/telemetry"
35
38
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
36
39
"sigs.k8s.io/cluster-api/util"
37
40
"sigs.k8s.io/cluster-api/util/annotations"
@@ -62,6 +65,14 @@ type GCPClusterReconciler struct {
62
65
func (r * GCPClusterReconciler ) SetupWithManager (ctx context.Context , mgr ctrl.Manager , options controller.Options ) error {
63
66
log := log .FromContext (ctx ).WithValues ("controller" , "GCPCluster" )
64
67
68
+ ctx , span := telemetry .Tracer ().Start (
69
+ ctx , "controllers.GCPClusterReconciler.SetupWithManager" ,
70
+ trace .WithAttributes (
71
+ attribute .String ("controller" , "GCPCluster" ),
72
+ ),
73
+ )
74
+ defer span .End ()
75
+
65
76
c , err := ctrl .NewControllerManagedBy (mgr ).
66
77
WithOptions (options ).
67
78
For (& infrav1.GCPCluster {}).
@@ -106,6 +117,17 @@ func (r *GCPClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
106
117
defer cancel ()
107
118
108
119
log := log .FromContext (ctx )
120
+
121
+ ctx , span := telemetry .Tracer ().Start (
122
+ ctx , "controllers.GCPClusterReconciler.Reconcile" ,
123
+ trace .WithAttributes (
124
+ attribute .String ("name" , req .Name ),
125
+ attribute .String ("namespace" , req .Namespace ),
126
+ attribute .String ("kind" , "GCPCluster" ),
127
+ ),
128
+ )
129
+ defer span .End ()
130
+
109
131
gcpCluster := & infrav1.GCPCluster {}
110
132
err := r .Get (ctx , req .NamespacedName , gcpCluster )
111
133
if err != nil {
@@ -161,6 +183,12 @@ func (r *GCPClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
161
183
162
184
func (r * GCPClusterReconciler ) reconcile (ctx context.Context , clusterScope * scope.ClusterScope ) (ctrl.Result , error ) {
163
185
log := log .FromContext (ctx )
186
+
187
+ ctx , span := telemetry .Tracer ().Start (
188
+ ctx , "controllers.GCPClusterReconciler.reconcile" ,
189
+ )
190
+ defer span .End ()
191
+
164
192
log .Info ("Reconciling GCPCluster" )
165
193
166
194
controllerutil .AddFinalizer (clusterScope .GCPCluster , infrav1 .ClusterFinalizer )
@@ -228,6 +256,12 @@ func (r *GCPClusterReconciler) reconcile(ctx context.Context, clusterScope *scop
228
256
229
257
func (r * GCPClusterReconciler ) reconcileDelete (ctx context.Context , clusterScope * scope.ClusterScope ) error {
230
258
log := log .FromContext (ctx )
259
+
260
+ ctx , span := telemetry .Tracer ().Start (
261
+ ctx , "controllers.GCPClusterReconciler.reconcileDelete" ,
262
+ )
263
+ defer span .End ()
264
+
231
265
log .Info ("Reconciling Delete GCPCluster" )
232
266
233
267
reconcilers := []cloud.Reconciler {
0 commit comments