Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1295 from microsoft/tilee/merge_develop_to_master…
Browse files Browse the repository at this point in the history
…(prep2.12-beta1)

merge develop to master(prep2.12 beta1)
  • Loading branch information
cijothomas authored Oct 17, 2019
2 parents 2825af8 + 660d9db commit 1f0e3af
Show file tree
Hide file tree
Showing 68 changed files with 1,069 additions and 265 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 2.12.0-beta1
- [Enhancement to how QuickPulseTelemetryModule shares its ServiceEndpoint with QuickPulseTelemetryProcessor.](https://github.com/microsoft/ApplicationInsights-dotnet-server/pull/1266)
- [QuickPulse will support SDK Connection String](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1221)
- [Add support for storing EventCounter Metadata as properties of MetricTelemetry](https://github.com/microsoft/ApplicationInsights-dotnet-server/issues/1287)
- [New RoleName initializer for Azure Web App to accurately populate RoleName.](https://github.com/microsoft/ApplicationInsights-dotnet-server/issues/1207)

## Version 2.11.2
- [Fix Sql dependency collection bug in .NET Core 3.0 with Microsoft.Data.SqlClient.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/1291)

Expand Down
8 changes: 4 additions & 4 deletions GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
Update for every public release.
-->
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>11</SemanticVersionMinor>
<SemanticVersionPatch>2</SemanticVersionPatch>
<SemanticVersionMinor>12</SemanticVersionMinor>
<SemanticVersionPatch>0</SemanticVersionPatch>
<!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone></PreReleaseMilestone>
<PreReleaseMilestone>beta1</PreReleaseMilestone>
<!--
Date when Semantic Version was changed.
Update for every public release.
NOTE!!!!!! Do not update when updating PreReleaseMilestone update
as it will restart file versions so 2.4.0-beta1 may have higher
file version (like 2.4.0.2222) than 2.4.0-beta2 (like 2.4.0.1111)
-->
<SemanticVersionDate>2019-07-08</SemanticVersionDate>
<SemanticVersionDate>2019-09-23</SemanticVersionDate>
<!--
Pre-release version is used to distinguish internally built NuGet packages.
Pre-release version = Minutes since semantic version was set, divided by 5 (to make it fit in a UInt16 (max 65535 = ~7 months).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Product.props" />

<PropertyGroup>
Expand Down Expand Up @@ -44,7 +44,7 @@

<ItemGroup>
<!--Common Dependencies-->
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.11.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0-beta1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<RootNamespace>Microsoft.ApplicationInsights.DependencyCollector</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationInsights, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.11.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
<Reference Include="Microsoft.ApplicationInsights, Version=2.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.12.0-beta1\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
Expand Down
2 changes: 1 addition & 1 deletion Src/DependencyCollector/Net45.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ApplicationInsights" version="2.11.0" targetFramework="net451" />
<package id="Microsoft.ApplicationInsights" version="2.12.0-beta1" targetFramework="net451" />
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net451" developmentDependency="true" />
<package id="System.Buffers" version="4.4.0" targetFramework="net451" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net451" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<ItemGroup>
<!--Common Dependencies-->
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.11.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0-beta1" />
</ItemGroup>

<Import Project="..\..\..\Src\Common\Common.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ private void ExtractAndPostMetric(string eventSourceName, IDictionary<string, ob
{
actualCount = Convert.ToInt32(payload.Value, CultureInfo.InvariantCulture);
}
else if (key.Equals("Metadata", StringComparison.OrdinalIgnoreCase))
{
var metadata = payload.Value.ToString();
if (!string.IsNullOrEmpty(metadata))
{
var keyValuePairStrings = metadata.Split(',');
foreach (var keyValuePairString in keyValuePairStrings)
{
var keyValuePair = keyValuePairString.Split(':');
if (!metricTelemetry.Properties.ContainsKey(keyValuePair[0]))
{
metricTelemetry.Properties.Add(keyValuePair[0], keyValuePair[1]);
}
}
}
}
}

if (calculateRate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<DefineConstants>$(DefineConstants);NET45</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationInsights, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.11.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
<Reference Include="Microsoft.ApplicationInsights, Version=2.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.12.0-beta1\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
</Reference>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>fakesAssemblyForBuild\Microsoft.QualityTools.Testing.Fakes.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MicroBuild.Core" version="0.3.0" targetFramework="net45" developmentDependency="true" />
<package id="Microsoft.ApplicationInsights" version="2.11.0" targetFramework="net45" />
<package id="Microsoft.ApplicationInsights" version="2.12.0-beta1" targetFramework="net45" />
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net45" developmentDependency="true" />
<package id="System.Buffers" version="4.4.0" targetFramework="net45" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net45" />
Expand Down
4 changes: 2 additions & 2 deletions Src/HostingStartup/HostingStartup/HostingStartup.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Product.props" />

<PropertyGroup>
Expand Down Expand Up @@ -40,7 +40,7 @@

<ItemGroup>
<!--Common Dependencies-->
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.11.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0-beta1" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@
</ItemGroup>

<Import Project="..\Perf.Shared.Tests\Perf.Shared.Tests.projitems" Label="Shared" />

<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@
</ItemGroup>

<Import Project="..\..\Perf.Shared.Tests\Perf.Shared.Tests.projitems" Label="Shared" />

<Import Project="..\..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationInsights, Version=2.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.11.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
<Reference Include="Microsoft.ApplicationInsights, Version=2.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.ApplicationInsights.2.12.0-beta1\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using Microsoft.ApplicationInsights.DataContracts;
Expand All @@ -19,6 +20,7 @@
public class PerformanceCollectorModulesTests
{
[TestMethod]
[SuppressMessage(category: "Microsoft.Globalization", checkId: "CA1305:SpecifyIFormatProvider", Justification = "Don't care about invariant in unit tests.")]
public void TimerTest()
{
var collector = CreatePerformanceCollector();
Expand Down Expand Up @@ -61,7 +63,7 @@ public void TimerTest()

lock (collector.Sync)
{
Assert.IsTrue(collector.Counters.TrueForAll(c => c.Item2.Count > 0), "Some of the counters have not been collected. Counter count: " + collector.Counters.Count + ", non-zero counter count: " + collector.Counters.Count(c => c.Item2.Count > 0));
Assert.IsTrue(collector.Counters.TrueForAll(c => c.Item2.Count > 0), $"Some of the counters have not been collected. Counter count: {collector.Counters.Count}, non-zero counter count: {collector.Counters.Count(c => c.Item2.Count > 0)}");
}

if (assertionsFailure != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void QuickPulseTelemetryModuleInteractsWithTelemetryProcessorCorrectlyWhe
var telemetryProcessor = config.TelemetryProcessors.OfType<QuickPulseTelemetryProcessor>().SingleOrDefault();
Assert.IsNotNull(telemetryProcessor);

Assert.AreEqual(telemetryProcessor, QuickPulseTestHelper.GetTelemetryProcessors(module).SingleOrDefault());
Assert.AreEqual(telemetryProcessor, module.TelemetryProcessors.SingleOrDefault());
}

[TestMethod]
Expand Down Expand Up @@ -72,7 +72,7 @@ public void QuickPulseTelemetryModuleInteractsWithTelemetryProcessorCorrectlyWhe
var telemetryProcessor = config.TelemetryProcessors.OfType<QuickPulseTelemetryProcessor>().SingleOrDefault();
Assert.IsNotNull(telemetryProcessor);

Assert.AreEqual(telemetryProcessor, QuickPulseTestHelper.GetTelemetryProcessors(module).SingleOrDefault());
Assert.AreEqual(telemetryProcessor, module.TelemetryProcessors.SingleOrDefault());
}

[TestMethod]
Expand Down Expand Up @@ -109,10 +109,9 @@ public void QuickPulseTelemetryModuleSupportsMultipleTelemetryProcessorsForSingl

// ASSERT
var module = TelemetryModules.Instance.Modules.OfType<QuickPulseTelemetryModule>().SingleOrDefault();
var registeredProcessors = QuickPulseTestHelper.GetTelemetryProcessors(module);

Assert.AreEqual(TelemetryProcessorCount + 1, registeredProcessors.Count); // one was there after the initial configuration loading
Assert.IsTrue(telemetryProcessors.TrueForAll(registeredProcessors.Contains));
Assert.AreEqual(TelemetryProcessorCount + 1, module.TelemetryProcessors.Count); // one was there after the initial configuration loading
Assert.IsTrue(telemetryProcessors.TrueForAll(module.TelemetryProcessors.Contains));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,15 @@ public void QuickPulseTopCpuCollectorCleansUpStateWhenProcessesGoAway()
var timeProvider = new ClockMock();
var collector = new QuickPulseTopCpuCollector(timeProvider, processProvider);

var processDictionary =
QuickPulseTestHelper.GetPrivateField(collector, "processObservations") as Dictionary<string, TimeSpan>;

// ACT
collector.GetTopProcessesByCpu(3);
int itemCount1 = processDictionary.Count;
int itemCount1 = collector.ProcessObservations.Count;

timeProvider.FastForward(TimeSpan.FromSeconds(1));

processProvider.Processes = new List<QuickPulseProcess>() { new QuickPulseProcess("Process1", baseProcessorTime) };
collector.GetTopProcessesByCpu(3);
int itemCount3 = processDictionary.Count;
int itemCount3 = collector.ProcessObservations.Count;

// ASSERT
Assert.AreEqual(5, itemCount1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ApplicationInsights" version="2.11.0" targetFramework="net45" />
<package id="Microsoft.ApplicationInsights" version="2.12.0-beta1" targetFramework="net45" />
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net45" />
<package id="System.Buffers" version="4.4.0" targetFramework="net45" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
/// </summary>
internal sealed class QuickPulseTopCpuCollector : IQuickPulseTopCpuCollector
{
// process name => (last observation timestamp, last observation value)
internal readonly Dictionary<string, TimeSpan> ProcessObservations = new Dictionary<string, TimeSpan>(StringComparer.Ordinal);

private readonly TimeSpan accessDeniedRetryInterval = TimeSpan.FromMinutes(1);

private readonly Clock timeProvider;

private readonly IQuickPulseProcessProvider processProvider;

// process name => (last observation timestamp, last observation value)
private readonly Dictionary<string, TimeSpan> processObservations = new Dictionary<string, TimeSpan>(StringComparer.Ordinal);

private DateTimeOffset prevObservationTime;

private TimeSpan? prevOverallTime;
Expand Down Expand Up @@ -86,17 +86,17 @@ public IEnumerable<Tuple<string, int>> GetTopProcessesByCpu(int topN)
encounteredProcs.Add(process.ProcessName);

TimeSpan lastObservation;
if (!this.processObservations.TryGetValue(process.ProcessName, out lastObservation))
if (!this.ProcessObservations.TryGetValue(process.ProcessName, out lastObservation))
{
// this is the first time we're encountering this process
this.processObservations.Add(process.ProcessName, process.TotalProcessorTime);
this.ProcessObservations.Add(process.ProcessName, process.TotalProcessorTime);

continue;
}

TimeSpan cpuTimeSinceLast = process.TotalProcessorTime - lastObservation;

this.processObservations[process.ProcessName] = process.TotalProcessorTime;
this.ProcessObservations[process.ProcessName] = process.TotalProcessorTime;

// use perf data if available; otherwise, calculate it ourselves
TimeSpan timeElapsedOnAllCoresSinceLast = (totalTime - this.prevOverallTime)
Expand Down Expand Up @@ -168,10 +168,10 @@ public void Close()
private void CleanState(HashSet<string> encounteredProcs)
{
// remove processes that we haven't encountered this time around
string[] processCpuKeysToRemove = this.processObservations.Keys.Where(p => !encounteredProcs.Contains(p)).ToArray();
string[] processCpuKeysToRemove = this.ProcessObservations.Keys.Where(p => !encounteredProcs.Contains(p)).ToArray();
foreach (var key in processCpuKeysToRemove)
{
this.processObservations.Remove(key);
this.ProcessObservations.Remove(key);
}
}
}
Expand Down
Loading

0 comments on commit 1f0e3af

Please sign in to comment.