-
Notifications
You must be signed in to change notification settings - Fork 249
fix: Fixing CNI Telemtry Service run by CNS #3824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ | |
// Service name. | ||
name = "azure-cns" | ||
pluginName = "azure-vnet" | ||
aiPluginName = "AzureCNI" | ||
endpointStoreName = "azure-endpoints" | ||
endpointStoreLocationLinux = "/var/run/azure-cns/" | ||
endpointStoreLocationWindows = "/k/azurecns/" | ||
|
@@ -470,11 +471,36 @@ | |
return nil | ||
} | ||
|
||
func startTelemetryService(ctx context.Context) { | ||
var config aitelemetry.AIConfig | ||
func startTelemetryService(ctx context.Context, cnsconfig *configuration.CNSConfig) { | ||
// Use the same telemetry settings as the main CNS service | ||
ts := cnsconfig.TelemetrySettings | ||
|
||
// Check if telemetry is disabled | ||
if ts.DisableAll { | ||
logger.Printf("Telemetry is disabled, skipping CNI telemetry service") | ||
Check failure on line 480 in cns/service/main.go
|
||
return | ||
} | ||
|
||
aiConfig := aitelemetry.AIConfig{ | ||
AppName: aiPluginName, | ||
AppVersion: version, | ||
BatchSize: ts.TelemetryBatchSizeBytes, | ||
BatchInterval: ts.TelemetryBatchIntervalInSecs, | ||
RefreshTimeout: ts.RefreshIntervalInSecs, | ||
DisableMetadataRefreshThread: ts.DisableMetadataRefreshThread, | ||
DebugMode: ts.DebugMode, | ||
} | ||
|
||
tb := telemetry.NewTelemetryBuffer(nil) | ||
err := tb.CreateAITelemetryHandle(config, false, false, false) | ||
|
||
var err error | ||
if cnsconfig.TelemetrySettings.AppInsightsInstrumentationKey != "" { | ||
err = tb.CreateAITelemetryHandle(aiConfig, ts.DisableTrace, ts.DisableMetric, ts.DisableEvent) | ||
} else { | ||
logger.Printf("No Application Insights key provided for CNI telemetry service") | ||
Check failure on line 500 in cns/service/main.go
|
||
Comment on lines
+497
to
+500
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should check other way and remove else?
|
||
return | ||
} | ||
|
||
if err != nil { | ||
logger.Errorf("AI telemetry handle creation failed: %v", err) | ||
return | ||
|
@@ -705,7 +731,7 @@ | |
|
||
if telemetryDaemonEnabled { | ||
logger.Printf("CNI Telemetry is enabled") | ||
go startTelemetryService(rootCtx) | ||
go startTelemetryService(rootCtx, cnsconfig) | ||
} | ||
|
||
// Log platform information. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the PR title 'Telemtry' which should be 'Telemetry'. While this constant name is correct, ensure consistency in naming throughout the codebase.
Copilot uses AI. Check for mistakes.