Skip to content

Commit

Permalink
Upgrade Microsoft.ApplicationInsights from 2.4.0 to 2.12.0 (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
msJinLei authored Jul 6, 2021
1 parent 98a1ebd commit b117855
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions src/Common/MetricHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public MetricHelper(INetworkHelper network)
#if DEBUG
if (TestMockSupport.RunningMocked)
{
TelemetryConfiguration.Active.DisableTelemetry = true;
telemetryConfiguration.DisableTelemetry = true;
}
#endif
}
Expand Down Expand Up @@ -425,7 +425,7 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string,
private static string[] exceptionTrackAcceptModuleList = { "Az.Accounts", "Az.Compute", "Az.AKS", "Az.ContainerRegistry" };
private static string[] exceptionTrackAcceptCmdletList = { "Get-AzKeyVaultSecret", "Get-AzKeyVaultCert" };

private static string ConvertFrameToString(StackFrame frame)
private static string ConvertFrameToString(System.Diagnostics.StackFrame frame)
{
string[] fullNameParts = frame?.GetMethod()?.DeclaringType?.FullName?.Split('.');
if(fullNameParts == null || fullNameParts.Length == 0)
Expand Down Expand Up @@ -513,6 +513,16 @@ public static Dictionary<string, string> SerializeCustomEventPayload<T>(T payloa

return JsonConvert.DeserializeObject<Dictionary<string, string>>(payloadAsJson);
}

private static TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration()
{
InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090"
};

public void AddDefaultTelemetryClient()
{
AddTelemetryClient(new TelemetryClient(telemetryConfiguration));
}
}
}

Expand Down

0 comments on commit b117855

Please sign in to comment.