@@ -94,6 +94,7 @@ const (
9494 // Service name.
9595 name = "azure-cns"
9696 pluginName = "azure-vnet"
97+ aiPluginName = "AzureCNI"
9798 endpointStoreName = "azure-endpoints"
9899 endpointStoreLocationLinux = "/var/run/azure-cns/"
99100 endpointStoreLocationWindows = "/k/azurecns/"
@@ -470,11 +471,36 @@ func sendRegisterNodeRequest(ctx context.Context, httpClient httpDoer, httpRestS
470471 return nil
471472}
472473
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+ }
475493
476494 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+
478504 if err != nil {
479505 logger .Errorf ("AI telemetry handle creation failed: %v" , err )
480506 return
@@ -705,7 +731,7 @@ func main() {
705731
706732 if telemetryDaemonEnabled {
707733 logger .Printf ("CNI Telemetry is enabled" )
708- go startTelemetryService (rootCtx )
734+ go startTelemetryService (rootCtx , cnsconfig )
709735 }
710736
711737 // Log platform information.
0 commit comments