Skip to content

Commit 5461753

Browse files
authored
Upgrade ApplicationInsights 2.13.1 (Azure#348)
* Upgrade ApplicationInsights * update code after review * remove using * revise code after review
1 parent 516200e commit 5461753

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

src/Common/AzurePSCmdlet.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ protected void LogQosEvent()
765765
{
766766
_metricHelper.LogQoSEvent(_qosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
767767
_metricHelper.FlushMetric();
768-
WriteDebug("Finish sending metric.");
769768
}
770769
catch (Exception e)
771770
{

src/Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</ItemGroup>
6464

6565
<ItemGroup>
66-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0" />
66+
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.13.1" />
6767
</ItemGroup>
6868

6969
<ItemGroup>

src/Common/MetricHelper.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
using Microsoft.ApplicationInsights.DataContracts;
1717
using Microsoft.ApplicationInsights.Extensibility;
1818
using Microsoft.Azure.Commands.Common;
19-
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
2019
using Microsoft.Azure.Commands.Common.Authentication;
20+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
2121
using Microsoft.Azure.PowerShell.Common.Share;
2222
using Microsoft.Rest.Azure;
2323
using Microsoft.WindowsAzure.Commands.Common.Utilities;
@@ -31,13 +31,13 @@
3131
using System.Management.Automation.Host;
3232
using System.Security.Cryptography;
3333
using System.Text;
34+
using System.Threading.Tasks;
3435

3536
namespace Microsoft.WindowsAzure.Commands.Common
3637
{
3738
public class MetricHelper
3839
{
3940
protected INetworkHelper _networkHelper;
40-
private const int FlushTimeoutInMilli = 5000;
4141
private const string DefaultPSVersion = "3.0.0.0";
4242
private const string EventName = "cmdletInvocation";
4343

@@ -481,17 +481,25 @@ public void FlushMetric()
481481
return;
482482
}
483483

484-
try
484+
Task flushMetricTask = FlushMetricAsync(TelemetryClients);
485+
}
486+
487+
private async Task FlushMetricAsync(IEnumerable<TelemetryClient> TelemetryClients)
488+
{
489+
await Task.Run(() =>
485490
{
486491
foreach (TelemetryClient client in TelemetryClients)
487492
{
488-
client.Flush();
493+
try
494+
{
495+
client.Flush();
496+
}
497+
catch
498+
{
499+
// ignored
500+
}
489501
}
490-
}
491-
catch
492-
{
493-
// ignored
494-
}
502+
});
495503
}
496504

497505
/// <summary>

0 commit comments

Comments
 (0)