@@ -94,6 +94,7 @@ const (
94
94
// Service name.
95
95
name = "azure-cns"
96
96
pluginName = "azure-vnet"
97
+ aiPluginName = "AzureCNI"
97
98
endpointStoreName = "azure-endpoints"
98
99
endpointStoreLocationLinux = "/var/run/azure-cns/"
99
100
endpointStoreLocationWindows = "/k/azurecns/"
@@ -470,11 +471,36 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS
470
471
return nil
471
472
}
472
473
473
- func startTelemetryService (ctx context.Context ) {
474
- var config aitelemetry.AIConfig
474
+ func startTelemetryService (ctx context.Context , cnsconfig * configuration.CNSConfig ) {
475
+ // Use the same telemetry settings as the main CNS service
476
+ ts := cnsconfig .TelemetrySettings
477
+
478
+ // Check if telemetry is disabled
479
+ if ts .DisableAll {
480
+ logger .Printf ("Telemetry is disabled, skipping CNI telemetry service" )
481
+ return
482
+ }
483
+
484
+ aiConfig := aitelemetry.AIConfig {
485
+ AppName : aiPluginName ,
486
+ AppVersion : version ,
487
+ BatchSize : ts .TelemetryBatchSizeBytes ,
488
+ BatchInterval : ts .TelemetryBatchIntervalInSecs ,
489
+ RefreshTimeout : ts .RefreshIntervalInSecs ,
490
+ DisableMetadataRefreshThread : ts .DisableMetadataRefreshThread ,
491
+ DebugMode : ts .DebugMode ,
492
+ }
475
493
476
494
tb := telemetry .NewTelemetryBuffer (nil )
477
- err := tb .CreateAITelemetryHandle (config , false , false , false )
495
+
496
+ var err error
497
+ if aiKey := cnsconfig .TelemetrySettings .AppInsightsInstrumentationKey ; aiKey != "" {
498
+ err = tb .CreateAITelemetryHandle (aiConfig , ts .DisableTrace , ts .DisableMetric , ts .DisableEvent )
499
+ } else {
500
+ logger .Printf ("No Application Insights key provided for CNI telemetry service" )
501
+ return
502
+ }
503
+
478
504
if err != nil {
479
505
logger .Errorf ("AI telemetry handle creation failed: %v" , err )
480
506
return
@@ -705,7 +731,7 @@ func main() {
705
731
706
732
if telemetryDaemonEnabled {
707
733
logger .Printf ("CNI Telemetry is enabled" )
708
- go startTelemetryService (rootCtx )
734
+ go startTelemetryService (rootCtx , cnsconfig )
709
735
}
710
736
711
737
// Log platform information.
0 commit comments