From 78ca6c98ec1c4e1bff97d51d35324f2c01048ac5 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 13 Jul 2021 13:47:55 -0700 Subject: [PATCH 01/17] turn off telemetry --- src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj | 1 + src/Microsoft.DotNet.SignTool/src/SignToolTask.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index 8bd296befef..0ae9c7548ef 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -29,6 +29,7 @@ <_DesktopMSBuildRequired>false <_DesktopMSBuildRequired Condition="'$(_DryRun)' != 'true' and '$(MSBuildRuntimeType)' == 'Core'">true + <_TurnOffTelemetry Condition="'$(TurnOffTelemetry)' == ''">false public bool TestSign { get; set; } + /// + /// Turn off Telmetry is added to turn off telemetry for linux signing in release pipeline, but by default its always false + /// + public bool TurnOffTelemetry {get; set;} + /// /// True to perform strong name check on signed files. /// If enabled it will require SNBinaryPath to be informed. @@ -263,7 +268,10 @@ public void ExecuteImpl() } finally { - telemetry.SendEvents(); + if (TurnOffTelemetry) + { + telemetry.SendEvents(); + } } } From fee79984ef374f22a0589d24ab84baed787fabc6 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 13 Jul 2021 14:47:27 -0700 Subject: [PATCH 02/17] add turnOffTelemetry to task --- src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index 0ae9c7548ef..ac8e4093e6f 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -62,6 +62,7 @@ LogDir="$(ArtifactsLogDir)" MSBuildPath="$(_DesktopMSBuildPath)" SNBinaryPath="$(NuGetPackageRoot)sn\$(SNVersion)\sn.exe" - MicroBuildCorePath="$(NuGetPackageRoot)microbuild.core\$(MicroBuildCoreVersion)"/> + MicroBuildCorePath="$(NuGetPackageRoot)microbuild.core\$(MicroBuildCoreVersion)" + TurnOffTelemetry="$(TurnOffTelemetry)/> From c307473fa4b092bcc31cfb9783e21ce45ab9a1e5 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 13 Jul 2021 15:19:39 -0700 Subject: [PATCH 03/17] typo --- src/Microsoft.DotNet.SignTool/src/SignToolTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs index 40ba6d1d9a2..3941472a67f 100644 --- a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs +++ b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs @@ -268,7 +268,7 @@ public void ExecuteImpl() } finally { - if (TurnOffTelemetry) + if (!TurnOffTelemetry) { telemetry.SendEvents(); } From 5d6f3e67bfbf4833103c6d5daf88353cc189a565 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Wed, 14 Jul 2021 11:49:48 -0700 Subject: [PATCH 04/17] Added some comments --- src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj | 6 ++++-- src/Microsoft.DotNet.SignTool/src/SignToolTask.cs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index ac8e4093e6f..ae037854c7f 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -29,7 +29,9 @@ <_DesktopMSBuildRequired>false <_DesktopMSBuildRequired Condition="'$(_DryRun)' != 'true' and '$(MSBuildRuntimeType)' == 'Core'">true - <_TurnOffTelemetry Condition="'$(TurnOffTelemetry)' == ''">false + + <_TurnOffTelemetry>true + <_TurnOffTelemetry Condition="'$(TurnOffTelemetry)' == ''">false diff --git a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs index 3941472a67f..d0778896ab2 100644 --- a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs +++ b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs @@ -38,6 +38,7 @@ public class SignToolTask : BuildTask /// /// Turn off Telmetry is added to turn off telemetry for linux signing in release pipeline, but by default its always false + /// Issue tracking this https://github.com/dotnet/arcade/issues/7621 /// public bool TurnOffTelemetry {get; set;} From 6f542ea66716ded32b71d868e96f91737c5dca07 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Wed, 14 Jul 2021 14:32:53 -0700 Subject: [PATCH 05/17] review comments --- src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj | 6 +++--- src/Microsoft.DotNet.SignTool/src/SignToolTask.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index ae037854c7f..d937cb6e6f5 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -30,8 +30,8 @@ <_DesktopMSBuildRequired>false <_DesktopMSBuildRequired Condition="'$(_DryRun)' != 'true' and '$(MSBuildRuntimeType)' == 'Core'">true - <_TurnOffTelemetry>true - <_TurnOffTelemetry Condition="'$(TurnOffTelemetry)' == ''">false + <_DisableTelemetry>false + <_DisableTelemetry Condition="'$(DisableTelemetry)' != ''">$(DisableTelemetry) diff --git a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs index d0778896ab2..08bb395b0ba 100644 --- a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs +++ b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs @@ -40,7 +40,7 @@ public class SignToolTask : BuildTask /// Turn off Telmetry is added to turn off telemetry for linux signing in release pipeline, but by default its always false /// Issue tracking this https://github.com/dotnet/arcade/issues/7621 /// - public bool TurnOffTelemetry {get; set;} + public bool DisableTelemetry {get; set;} /// /// True to perform strong name check on signed files. @@ -269,7 +269,7 @@ public void ExecuteImpl() } finally { - if (!TurnOffTelemetry) + if (!DisableTelemetry) { telemetry.SendEvents(); } From 5f81e186932be4418d8693e3503d08dfcaf0fa5e Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Wed, 14 Jul 2021 14:45:50 -0700 Subject: [PATCH 06/17] remove comments --- src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj | 1 - src/Microsoft.DotNet.SignTool/src/SignToolTask.cs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index d937cb6e6f5..755ea1005e0 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -29,7 +29,6 @@ <_DesktopMSBuildRequired>false <_DesktopMSBuildRequired Condition="'$(_DryRun)' != 'true' and '$(MSBuildRuntimeType)' == 'Core'">true - <_DisableTelemetry>false <_DisableTelemetry Condition="'$(DisableTelemetry)' != ''">$(DisableTelemetry) diff --git a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs index 08bb395b0ba..a31bfae19aa 100644 --- a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs +++ b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs @@ -37,8 +37,7 @@ public class SignToolTask : BuildTask public bool TestSign { get; set; } /// - /// Turn off Telmetry is added to turn off telemetry for linux signing in release pipeline, but by default its always false - /// Issue tracking this https://github.com/dotnet/arcade/issues/7621 + /// Enable or disable telemetry /// public bool DisableTelemetry {get; set;} From 604c41bdba719b544485c0504dfa1ab8ff437b8c Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Wed, 14 Jul 2021 17:47:24 -0700 Subject: [PATCH 07/17] test fix --- .../tools/Sign.proj | 5 +--- .../src/SignToolTask.cs | 10 +------ .../src/Telemetry.cs | 26 +++++++++++++------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj index 755ea1005e0..8bd296befef 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj @@ -29,8 +29,6 @@ <_DesktopMSBuildRequired>false <_DesktopMSBuildRequired Condition="'$(_DryRun)' != 'true' and '$(MSBuildRuntimeType)' == 'Core'">true - <_DisableTelemetry>false - <_DisableTelemetry Condition="'$(DisableTelemetry)' != ''">$(DisableTelemetry) diff --git a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs index a31bfae19aa..48c970c8385 100644 --- a/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs +++ b/src/Microsoft.DotNet.SignTool/src/SignToolTask.cs @@ -36,11 +36,6 @@ public class SignToolTask : BuildTask /// public bool TestSign { get; set; } - /// - /// Enable or disable telemetry - /// - public bool DisableTelemetry {get; set;} - /// /// True to perform strong name check on signed files. /// If enabled it will require SNBinaryPath to be informed. @@ -268,10 +263,7 @@ public void ExecuteImpl() } finally { - if (!DisableTelemetry) - { - telemetry.SendEvents(); - } + telemetry.SendEvents(); } } diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index 7faf1af06d4..cac07aa2ceb 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -20,6 +20,10 @@ internal class Telemetry { "BUILD_SOURCEVERSION", Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION") } }; + private static string disableTelemetry = Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"); + + private bool enableTelemetry = false; + public Telemetry() { _metrics = new Dictionary(); @@ -27,19 +31,25 @@ public Telemetry() internal void AddMetric(string name, double value) { - _metrics.Add(name, value); + if (!bool.TryParse(disableTelemetry, out enableTelemetry)) + { + _metrics.Add(name, value); + } + } internal void SendEvents() { - // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry - TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); - - TelemetryClient telemetryClient = new TelemetryClient(configuration); + if (!bool.TryParse(disableTelemetry, out enableTelemetry)) + { + // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry + TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); + TelemetryClient telemetryClient = new TelemetryClient(configuration); - telemetryClient.TrackEvent(s_sendEventName, properties: s_properties, metrics: _metrics); - telemetryClient.Flush(); - _metrics = null; + telemetryClient.TrackEvent(s_sendEventName, properties: s_properties, metrics: _metrics); + telemetryClient.Flush(); + _metrics = null; + } } } } From d4135c6756281c8bf312d07b0a99d4da632923de Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 15 Jul 2021 15:39:15 -0700 Subject: [PATCH 08/17] Test --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index cac07aa2ceb..4cee45be55d 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -22,25 +22,31 @@ internal class Telemetry private static string disableTelemetry = Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"); - private bool enableTelemetry = false; - public Telemetry() { _metrics = new Dictionary(); } + internal bool DisableTelemetry(string disableTelemetry) + { + if (!bool.TryParse(Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"), out var telemetrySwitch)) + { + telemetrySwitch = false; // the default if the variable isn't set + } + return telemetrySwitch; + } + internal void AddMetric(string name, double value) { - if (!bool.TryParse(disableTelemetry, out enableTelemetry)) + if (DisableTelemetry(disableTelemetry)) { _metrics.Add(name, value); } - } internal void SendEvents() { - if (!bool.TryParse(disableTelemetry, out enableTelemetry)) + if (DisableTelemetry(disableTelemetry)) { // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); From 8e5a9807c4f3f712fffd7cde956bd6e32ef078bb Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 15 Jul 2021 17:52:12 -0700 Subject: [PATCH 09/17] last time --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index 4cee45be55d..0118c5da591 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -29,7 +29,7 @@ public Telemetry() internal bool DisableTelemetry(string disableTelemetry) { - if (!bool.TryParse(Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"), out var telemetrySwitch)) + if (!bool.TryParse(Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"), out bool telemetrySwitch)) { telemetrySwitch = false; // the default if the variable isn't set } @@ -38,7 +38,7 @@ internal bool DisableTelemetry(string disableTelemetry) internal void AddMetric(string name, double value) { - if (DisableTelemetry(disableTelemetry)) + if (!DisableTelemetry(disableTelemetry)) { _metrics.Add(name, value); } @@ -46,7 +46,7 @@ internal void AddMetric(string name, double value) internal void SendEvents() { - if (DisableTelemetry(disableTelemetry)) + if (!DisableTelemetry(disableTelemetry)) { // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); From 3528d90338ad8a72a75791480a8ac69875b046ca Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Fri, 16 Jul 2021 10:54:21 -0700 Subject: [PATCH 10/17] Updated comments --- eng/Versions.props | 10 +++++----- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 97c23f36f28..733b9af0655 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -35,7 +35,7 @@ 2.1.1 2.1.0 3.10.0-4.21329.37 - 6.0.100-preview.6.21363.1 + 6.0.100-preview.6.21362.3 16.7.1 4.8.3 5.3.0.1 @@ -65,8 +65,8 @@ 2.4.1 2.0.3 2.4.1 - 6.0.0-beta.21363.2 - 6.0.0-beta.21363.2 + 6.0.0-beta.21359.3 + 6.0.0-beta.21359.3 1.22.0 1.1.2 2.0.0 @@ -77,8 +77,8 @@ 1.1.0-beta.20258.6 1.1.0-beta-21309-01 1.1.0-beta-21309-01 - 6.0.0-beta.21363.2 - 1.0.0-beta.21364.1 + 6.0.0-beta.21359.3 + 1.0.0-beta.21358.1 1.1.0-beta.21228.1 1.0.0-prerelease.21357.4 1.1.156602 diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index 0118c5da591..f124748fac4 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -20,25 +20,24 @@ internal class Telemetry { "BUILD_SOURCEVERSION", Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION") } }; - private static string disableTelemetry = Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"); - public Telemetry() { _metrics = new Dictionary(); } - internal bool DisableTelemetry(string disableTelemetry) + // enable or disable telemetry + internal bool DisableTelemetry() { if (!bool.TryParse(Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"), out bool telemetrySwitch)) { - telemetrySwitch = false; // the default if the variable isn't set + telemetrySwitch = false; } return telemetrySwitch; } internal void AddMetric(string name, double value) { - if (!DisableTelemetry(disableTelemetry)) + if (!DisableTelemetry()) { _metrics.Add(name, value); } @@ -46,7 +45,7 @@ internal void AddMetric(string name, double value) internal void SendEvents() { - if (!DisableTelemetry(disableTelemetry)) + if (!DisableTelemetry()) { // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); From a5060bb73b3c23d4fd3d5205b677e0d783d1b3d8 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Fri, 16 Jul 2021 11:20:08 -0700 Subject: [PATCH 11/17] merge conflict --- eng/Versions.props | 9 --------- 1 file changed, 9 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 3128f5e6605..22bbad9243c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -35,11 +35,7 @@ 2.1.1 2.1.0 3.10.0-4.21329.37 -<<<<<<< HEAD - 6.0.100-preview.6.21362.3 -======= 6.0.100-preview.6.21365.1 ->>>>>>> b03966cd85285e425ffe56003c0ab57e103dd14e 16.7.1 4.8.3 5.3.0.1 @@ -81,13 +77,8 @@ 1.1.0-beta.20258.6 1.1.0-beta-21309-01 1.1.0-beta-21309-01 -<<<<<<< HEAD - 6.0.0-beta.21359.3 - 1.0.0-beta.21358.1 -======= 6.0.0-beta.21365.11 1.0.0-beta.21365.1 ->>>>>>> b03966cd85285e425ffe56003c0ab57e103dd14e 1.1.0-beta.21228.1 1.0.0-prerelease.21357.4 1.1.156602 From aa17a0f2bae3a23829772cc4e7f4af2bb8fd3f9e Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Fri, 16 Jul 2021 13:17:41 -0700 Subject: [PATCH 12/17] test --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index f124748fac4..568b2fc1538 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -20,9 +20,12 @@ internal class Telemetry { "BUILD_SOURCEVERSION", Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION") } }; + private static bool disableTelemetry; + public Telemetry() { _metrics = new Dictionary(); + disableTelemetry = DisableTelemetry(); } // enable or disable telemetry @@ -37,7 +40,7 @@ internal bool DisableTelemetry() internal void AddMetric(string name, double value) { - if (!DisableTelemetry()) + if (!disableTelemetry) { _metrics.Add(name, value); } @@ -45,7 +48,7 @@ internal void AddMetric(string name, double value) internal void SendEvents() { - if (!DisableTelemetry()) + if (!disableTelemetry) { // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); From 130c6701b54c373e7bdb9a3a1c541f9cabb7f0dd Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Mon, 19 Jul 2021 09:48:34 -0700 Subject: [PATCH 13/17] rename variable --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index 568b2fc1538..cde44e8d9e9 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -31,7 +31,7 @@ public Telemetry() // enable or disable telemetry internal bool DisableTelemetry() { - if (!bool.TryParse(Environment.GetEnvironmentVariable("DISABLE_TELEMETRY"), out bool telemetrySwitch)) + if (!bool.TryParse(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"), out bool telemetrySwitch)) { telemetrySwitch = false; } From 15d9c2b92c212704d34724959a9bf0277209ef6a Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Mon, 19 Jul 2021 10:08:58 -0700 Subject: [PATCH 14/17] comments --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index cde44e8d9e9..c1575a4f8d8 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -20,12 +20,12 @@ internal class Telemetry { "BUILD_SOURCEVERSION", Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION") } }; - private static bool disableTelemetry; + private static bool _disableTelemetry; public Telemetry() { _metrics = new Dictionary(); - disableTelemetry = DisableTelemetry(); + _disableTelemetry = DisableTelemetry(); } // enable or disable telemetry @@ -40,7 +40,7 @@ internal bool DisableTelemetry() internal void AddMetric(string name, double value) { - if (!disableTelemetry) + if (!_disableTelemetry) { _metrics.Add(name, value); } @@ -48,7 +48,7 @@ internal void AddMetric(string name, double value) internal void SendEvents() { - if (!disableTelemetry) + if (!_disableTelemetry) { // set APPINSIGHTS_INSTRUMENTATIONKEY environment variable to begin tracking telemetry TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault(); From 788f864f20699d1003d4149e255ef309df575a9a Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 20 Jul 2021 11:53:52 -0700 Subject: [PATCH 15/17] review comments --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index c1575a4f8d8..587c558d2a4 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -20,22 +20,13 @@ internal class Telemetry { "BUILD_SOURCEVERSION", Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION") } }; - private static bool _disableTelemetry; + private readonly bool _disableTelemetry ; public Telemetry() { _metrics = new Dictionary(); - _disableTelemetry = DisableTelemetry(); - } - - // enable or disable telemetry - internal bool DisableTelemetry() - { - if (!bool.TryParse(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"), out bool telemetrySwitch)) - { - telemetrySwitch = false; - } - return telemetrySwitch; + _disableTelemetry = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY")) + && string.Equals(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"),"true"); } internal void AddMetric(string name, double value) From 2d895476f03f1c8eb2f6d10c6a5d3d9933ed4b06 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 20 Jul 2021 12:05:13 -0700 Subject: [PATCH 16/17] minor fix --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index 587c558d2a4..bbf123ed1b1 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -25,8 +25,8 @@ internal class Telemetry public Telemetry() { _metrics = new Dictionary(); - _disableTelemetry = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY")) - && string.Equals(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"),"true"); + _disableTelemetry = (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY")) + && string.Equals(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"),"true")); } internal void AddMetric(string name, double value) From 63c82ea8bc679188307d98cb65ee0bb86d8891c3 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Tue, 20 Jul 2021 12:56:47 -0700 Subject: [PATCH 17/17] comment --- src/Microsoft.DotNet.SignTool/src/Telemetry.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs index bbf123ed1b1..1910970a318 100644 --- a/src/Microsoft.DotNet.SignTool/src/Telemetry.cs +++ b/src/Microsoft.DotNet.SignTool/src/Telemetry.cs @@ -25,8 +25,8 @@ internal class Telemetry public Telemetry() { _metrics = new Dictionary(); - _disableTelemetry = (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY")) - && string.Equals(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"),"true")); + _disableTelemetry = + (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SIGNTOOL_DISABLE_TELEMETRY"))); } internal void AddMetric(string name, double value)