From a35b6b7142c243a7199a656091fe0a92644e31a8 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Fri, 2 Jul 2021 11:15:03 +0800 Subject: [PATCH] Upgrade Microsoft.ApplicationInsights from 2.4.0 to 2.12.0 --- src/Common/AzurePSCmdlet.cs | 8 ++------ src/Common/Common.csproj | 2 +- src/Common/MetricHelper.cs | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Common/AzurePSCmdlet.cs b/src/Common/AzurePSCmdlet.cs index 62ed48c40f..4169fd0cb9 100644 --- a/src/Common/AzurePSCmdlet.cs +++ b/src/Common/AzurePSCmdlet.cs @@ -12,13 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.ApplicationInsights; using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; +using Microsoft.Azure.PowerShell.Common.Share.Survey; using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.Common; using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.Azure.PowerShell.Common.Share.Survey; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -353,10 +352,7 @@ protected override void BeginProcessing() if (_metricHelper == null) { _metricHelper = new MetricHelper(profile); - _metricHelper.AddTelemetryClient(new TelemetryClient - { - InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090" - }); + _metricHelper.AddDefaultTelemetryClient(); } } } diff --git a/src/Common/Common.csproj b/src/Common/Common.csproj index 4b6508a895..7f922c7860 100644 --- a/src/Common/Common.csproj +++ b/src/Common/Common.csproj @@ -63,7 +63,7 @@ - + diff --git a/src/Common/MetricHelper.cs b/src/Common/MetricHelper.cs index d8233d8c84..d120aa8340 100644 --- a/src/Common/MetricHelper.cs +++ b/src/Common/MetricHelper.cs @@ -127,7 +127,7 @@ public MetricHelper(INetworkHelper network) #if DEBUG if (TestMockSupport.RunningMocked) { - TelemetryConfiguration.Active.DisableTelemetry = true; + telemetryConfiguration.DisableTelemetry = true; } #endif } @@ -425,7 +425,7 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary SerializeCustomEventPayload(T payloa return JsonConvert.DeserializeObject>(payloadAsJson); } + + private static TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration() + { + InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090" + }; + + public void AddDefaultTelemetryClient() + { + AddTelemetryClient(new TelemetryClient(telemetryConfiguration)); + } } }