From b5481b6ae927daad3482a9a57b18878b5b4cf34f Mon Sep 17 00:00:00 2001 From: Vishwanath Narasimhan Date: Tue, 12 Feb 2019 18:07:15 -0800 Subject: [PATCH 1/2] disable telemetry option --- source/code/go/src/plugins/telemetry.go | 5 +++++ source/code/plugin/ApplicationInsightsUtility.rb | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/source/code/go/src/plugins/telemetry.go b/source/code/go/src/plugins/telemetry.go index 82f970d3a..7f1dfd78c 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}") From 23ab0e5efb10a1a8d710985877a6996ae978f4fe Mon Sep 17 00:00:00 2001 From: Vishwanath Narasimhan Date: Tue, 12 Feb 2019 18:19:12 -0800 Subject: [PATCH 2/2] fix a typo --- source/code/go/src/plugins/telemetry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/code/go/src/plugins/telemetry.go b/source/code/go/src/plugins/telemetry.go index 7f1dfd78c..a64ca2218 100644 --- a/source/code/go/src/plugins/telemetry.go +++ b/source/code/go/src/plugins/telemetry.go @@ -120,7 +120,7 @@ func InitializeTelemetryClient(agentVersion string) (int, error) { } TelemetryClient = appinsights.NewTelemetryClient(string(decIkey)) - telemetryOffSwitch = os.Getenv("DISABLE_TELEMETRY") + telemetryOffSwitch := os.Getenv("DISABLE_TELEMETRY") if strings.Compare(strings.ToLower(telemetryOffSwitch), "true") == 0 { Log("Appinsights telemetry is disabled \n") TelemetryClient.SetIsEnabled(false)