@@ -27,6 +27,7 @@ import (
27
27
"k8s.io/utils/ptr"
28
28
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
29
29
"sigs.k8s.io/cluster-api-provider-gcp/cloud/gcperrors"
30
+ "sigs.k8s.io/cluster-api-provider-gcp/util/telemetry"
30
31
"sigs.k8s.io/controller-runtime/pkg/log"
31
32
)
32
33
@@ -48,6 +49,11 @@ const (
48
49
49
50
// Reconcile reconcile cluster control-plane loadbalancer components.
50
51
func (s * Service ) Reconcile (ctx context.Context ) error {
52
+ ctx , span := telemetry .Tracer ().Start (
53
+ ctx , "loadbalancers.Services.Reconcile" ,
54
+ )
55
+ defer span .End ()
56
+
51
57
log := log .FromContext (ctx )
52
58
log .Info ("Reconciling loadbalancer resources" )
53
59
@@ -82,6 +88,11 @@ func (s *Service) Reconcile(ctx context.Context) error {
82
88
83
89
// Delete deletes cluster control-plane loadbalancer components.
84
90
func (s * Service ) Delete (ctx context.Context ) error {
91
+ ctx , span := telemetry .Tracer ().Start (
92
+ ctx , "loadbalancers.Services.Delete" ,
93
+ )
94
+ defer span .End ()
95
+
85
96
log := log .FromContext (ctx )
86
97
var allErrs []error
87
98
lbSpec := s .scope .LoadBalancer ()
@@ -253,6 +264,11 @@ func (s *Service) createInternalLoadBalancer(ctx context.Context, name string, l
253
264
}
254
265
255
266
func (s * Service ) createOrGetInstanceGroups (ctx context.Context ) ([]* compute.InstanceGroup , error ) {
267
+ ctx , span := telemetry .Tracer ().Start (
268
+ ctx , "loadbalancers.Services.createOrGetInstanceGroups" ,
269
+ )
270
+ defer span .End ()
271
+
256
272
log := log .FromContext (ctx )
257
273
fd := s .scope .FailureDomains ()
258
274
zones := make ([]string , 0 , len (fd ))
@@ -297,6 +313,11 @@ func (s *Service) createOrGetInstanceGroups(ctx context.Context) ([]*compute.Ins
297
313
}
298
314
299
315
func (s * Service ) createOrGetHealthCheck (ctx context.Context , lbname string ) (* compute.HealthCheck , error ) {
316
+ ctx , span := telemetry .Tracer ().Start (
317
+ ctx , "loadbalancers.Services.createOrGetHealthCheck" ,
318
+ )
319
+ defer span .End ()
320
+
300
321
log := log .FromContext (ctx )
301
322
healthcheckSpec := s .scope .HealthCheckSpec (lbname )
302
323
log .V (2 ).Info ("Looking for healthcheck" , "name" , healthcheckSpec .Name )
@@ -324,6 +345,11 @@ func (s *Service) createOrGetHealthCheck(ctx context.Context, lbname string) (*c
324
345
}
325
346
326
347
func (s * Service ) createOrGetRegionalHealthCheck (ctx context.Context , lbname string ) (* compute.HealthCheck , error ) {
348
+ ctx , span := telemetry .Tracer ().Start (
349
+ ctx , "loadbalancers.Services.createOrGetBackendService" ,
350
+ )
351
+ defer span .End ()
352
+
327
353
log := log .FromContext (ctx )
328
354
healthcheckSpec := s .scope .HealthCheckSpec (lbname )
329
355
healthcheckSpec .Region = s .scope .Region ()
@@ -460,6 +486,11 @@ func (s *Service) createOrGetRegionalBackendService(ctx context.Context, lbname
460
486
}
461
487
462
488
func (s * Service ) createOrGetTargetTCPProxy (ctx context.Context , service * compute.BackendService ) (* compute.TargetTcpProxy , error ) {
489
+ ctx , span := telemetry .Tracer ().Start (
490
+ ctx , "loadbalancers.Services.createOrGetTargetTCPProxy" ,
491
+ )
492
+ defer span .End ()
493
+
463
494
log := log .FromContext (ctx )
464
495
targetSpec := s .scope .TargetTCPProxySpec ()
465
496
targetSpec .Service = service .SelfLink
@@ -488,6 +519,11 @@ func (s *Service) createOrGetTargetTCPProxy(ctx context.Context, service *comput
488
519
489
520
// createOrGetAddress is used to obtain a Global address.
490
521
func (s * Service ) createOrGetAddress (ctx context.Context , lbname string ) (* compute.Address , error ) {
522
+ ctx , span := telemetry .Tracer ().Start (
523
+ ctx , "loadbalancers.Services.createOrGetAddress" ,
524
+ )
525
+ defer span .End ()
526
+
491
527
log := log .FromContext (ctx )
492
528
addrSpec := s .scope .AddressSpec (lbname )
493
529
log .V (2 ).Info ("Looking for address" , "name" , addrSpec .Name )
@@ -553,6 +589,11 @@ func (s *Service) createOrGetInternalAddress(ctx context.Context, lbname string)
553
589
554
590
// createOrGetForwardingRule is used obtain a Global ForwardingRule.
555
591
func (s * Service ) createOrGetForwardingRule (ctx context.Context , lbname string , target * compute.TargetTcpProxy , addr * compute.Address ) (* compute.ForwardingRule , error ) {
592
+ ctx , span := telemetry .Tracer ().Start (
593
+ ctx , "loadbalancers.Services.createOrGetForwardingRule" ,
594
+ )
595
+ defer span .End ()
596
+
556
597
log := log .FromContext (ctx )
557
598
spec := s .scope .ForwardingRuleSpec (lbname )
558
599
spec .Target = target .SelfLink
@@ -655,6 +696,11 @@ func (s *Service) createOrGetRegionalForwardingRule(ctx context.Context, lbname
655
696
}
656
697
657
698
func (s * Service ) deleteForwardingRule (ctx context.Context , lbname string ) error {
699
+ ctx , span := telemetry .Tracer ().Start (
700
+ ctx , "loadbalancers.Services.deleteForwardingRule" ,
701
+ )
702
+ defer span .End ()
703
+
658
704
log := log .FromContext (ctx )
659
705
spec := s .scope .ForwardingRuleSpec (lbname )
660
706
key := meta .GlobalKey (spec .Name )
@@ -681,6 +727,11 @@ func (s *Service) deleteRegionalForwardingRule(ctx context.Context, lbname strin
681
727
}
682
728
683
729
func (s * Service ) deleteAddress (ctx context.Context , lbname string ) error {
730
+ ctx , span := telemetry .Tracer ().Start (
731
+ ctx , "loadbalancers.Services.deleteAddress" ,
732
+ )
733
+ defer span .End ()
734
+
684
735
log := log .FromContext (ctx )
685
736
spec := s .scope .AddressSpec (lbname )
686
737
key := meta .GlobalKey (spec .Name )
@@ -705,6 +756,11 @@ func (s *Service) deleteInternalAddress(ctx context.Context, lbname string) erro
705
756
}
706
757
707
758
func (s * Service ) deleteTargetTCPProxy (ctx context.Context ) error {
759
+ ctx , span := telemetry .Tracer ().Start (
760
+ ctx , "loadbalancers.Services.deleteTargetTCPProxy" ,
761
+ )
762
+ defer span .End ()
763
+
708
764
log := log .FromContext (ctx )
709
765
spec := s .scope .TargetTCPProxySpec ()
710
766
key := meta .GlobalKey (spec .Name )
@@ -718,6 +774,11 @@ func (s *Service) deleteTargetTCPProxy(ctx context.Context) error {
718
774
}
719
775
720
776
func (s * Service ) deleteBackendService (ctx context.Context , lbname string ) error {
777
+ ctx , span := telemetry .Tracer ().Start (
778
+ ctx , "loadbalancers.Services.deleteBackendService" ,
779
+ )
780
+ defer span .End ()
781
+
721
782
log := log .FromContext (ctx )
722
783
spec := s .scope .BackendServiceSpec (lbname )
723
784
key := meta .GlobalKey (spec .Name )
@@ -744,6 +805,11 @@ func (s *Service) deleteRegionalBackendService(ctx context.Context, lbname strin
744
805
}
745
806
746
807
func (s * Service ) deleteHealthCheck (ctx context.Context , lbname string ) error {
808
+ ctx , span := telemetry .Tracer ().Start (
809
+ ctx , "loadbalancers.Services.deleteHealthCheck" ,
810
+ )
811
+ defer span .End ()
812
+
747
813
log := log .FromContext (ctx )
748
814
spec := s .scope .HealthCheckSpec (lbname )
749
815
key := meta .GlobalKey (spec .Name )
@@ -770,6 +836,11 @@ func (s *Service) deleteRegionalHealthCheck(ctx context.Context, lbname string)
770
836
}
771
837
772
838
func (s * Service ) deleteInstanceGroups (ctx context.Context ) error {
839
+ ctx , span := telemetry .Tracer ().Start (
840
+ ctx , "loadbalancers.Services.deleteInstanceGroups" ,
841
+ )
842
+ defer span .End ()
843
+
773
844
log := log .FromContext (ctx )
774
845
for zone := range s .scope .Network ().APIServerInstanceGroups {
775
846
spec := s .scope .InstanceGroupSpec (zone )
0 commit comments