diff --git a/source/code/go/src/plugins/telemetry.go b/source/code/go/src/plugins/telemetry.go index 82f970d3a..a64ca2218 100644 --- a/source/code/go/src/plugins/telemetry.go +++ b/source/code/go/src/plugins/telemetry.go @@ -120,6 +120,11 @@ func InitializeTelemetryClient(agentVersion string) (int, error) { } TelemetryClient = appinsights.NewTelemetryClient(string(decIkey)) + telemetryOffSwitch := os.Getenv("DISABLE_TELEMETRY") + if strings.Compare(strings.ToLower(telemetryOffSwitch), "true") == 0 { + Log("Appinsights telemetry is disabled \n") + TelemetryClient.SetIsEnabled(false) + } CommonProperties = make(map[string]string) CommonProperties["Computer"] = Computer diff --git a/source/code/plugin/ApplicationInsightsUtility.rb b/source/code/plugin/ApplicationInsightsUtility.rb index 27660d708..683be0db4 100644 --- a/source/code/plugin/ApplicationInsightsUtility.rb +++ b/source/code/plugin/ApplicationInsightsUtility.rb @@ -61,9 +61,16 @@ def initializeUtility() @@CustomProperties['AgentVersion'] = ENV[@@EnvAgentVersion] @@CustomProperties['ControllerType'] = ENV[@@EnvControllerType] encodedAppInsightsKey = ENV[@@EnvApplicationInsightsKey] - if !encodedAppInsightsKey.nil? + + #Check if telemetry is turned off + telemetryOffSwitch = ENV['DISABLE_TELEMETRY'] + if telemetryOffSwitch && !telemetryOffSwitch.nil? && !telemetryOffSwitch.empty? && telemetryOffSwitch.downcase == "true".downcase + $log.warn("AppInsightsUtility: Telemetry is disabled") + @@Tc = ApplicationInsights::TelemetryClient.new + elsif !encodedAppInsightsKey.nil? decodedAppInsightsKey = Base64.decode64(encodedAppInsightsKey) @@Tc = ApplicationInsights::TelemetryClient.new decodedAppInsightsKey + end rescue => errorStr $log.warn("Exception in AppInsightsUtility: initilizeUtility - error: #{errorStr}")