This repository was archived by the owner on Jul 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Support Cross-Platform CPU and Memory counters. #1195
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ae8c21b
update test versions
cijothomas 8a0c1f7
Add CPU and Memory counter and modified factory to use this
cijothomas b690614
work in progress
cijothomas 1eb0f81
common factory for both perfcollector
cijothomas d28e14d
refacotrings to get separate collector per supported platform
cijothomas 4d6d047
Unit Test to GetPerformanceCollector
cijothomas b15e1c5
corrected namespaces
cijothomas 674498e
Separate XPlatformFactory added
cijothomas 51c4e12
rename netstandard20 to netstandard20net45.shared
cijothomas eaaf7c6
rename folder to match project
cijothomas cebff39
moved netstandard to separate shared project
cijothomas db474b1
More tests. fixed intance name issues in XPLatform
cijothomas 4dd5ba0
release build errors fixed
cijothomas 3e222c1
working stage.. need to do code refacoting and more unit testing next.
cijothomas 7489781
Ad more tests. Correct list of counters perf collector
cijothomas 97994e2
unit test for default counters list.
cijothomas fc50fb3
Getprocessor count odified to Env.ProcessorCount
cijothomas 75dd6d5
conflict resolutions
cijothomas 977f1b6
StringComparison.OrdinalIgnoreCase
cijothomas 907a706
one more StringComparison.OrdinalIgnoreCase
cijothomas 3d8a669
typo fix
cijothomas a163f88
fix build isues
cijothomas 78da3f7
start unit tests with PerformanceCounterUtility.isAzureWebApp = null …
cijothomas b527526
moved Getperfcollector to 3 separate methods for each preprocessor ta…
cijothomas 8d2ba9e
add information log about which collector is initiazlied
cijothomas e91a4b8
removed isCustomPerfCounter flag from everywhere. This was never used…
cijothomas f3ca0a4
resolved conflicts
cijothomas 8f63f51
minor stylecops and fix namespace
cijothomas 60f9a12
fix build
cijothomas d19293e
Merge branch 'develop' into cithomas/cpumemoryperfcounterxplat
cijothomas 82f72da
minors
cijothomas b31bf35
corrections
cijothomas 64eabf4
test fix
cijothomas 5cce929
add try catch
cijothomas be25d2e
comments addressing
cijothomas f5482bb
tests to dispose modules
cijothomas 37e9da3
ignroe temp some unstable test for investigation
cijothomas fb06d45
fix acidental stackoverflow caused by naming method
cijothomas 8b1ee1d
Address Dmitry pr comments
cijothomas 4a194da
fix steylop.
cijothomas 2fc4e76
corrected comment.
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ceCollector/NetCore20.Tests/Perf-NetCore20.Tests/PerformanceCollectorXPlatformTestBase.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| namespace Microsoft.ApplicationInsights.Tests | ||
| { | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector; | ||
| using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation; | ||
| using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.XPlatform; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| /// <summary> | ||
| /// PerformanceCollector test base. | ||
| /// </summary> | ||
| public class PerformanceCollectorXPlatformTestBase | ||
| { | ||
| internal void PerformanceCollectorSanityTest(IPerformanceCollector collector, string counter, string categoryName, string counterName, string instanceName) | ||
| { | ||
| const int CounterCount = 3; | ||
|
|
||
| for (int i = 0; i < CounterCount; i++) | ||
| { | ||
| string error; | ||
| collector.RegisterCounter( | ||
| counter, | ||
| null, | ||
| out error, | ||
| false); | ||
| } | ||
|
|
||
| var results = collector.Collect().ToList(); | ||
|
|
||
| Assert.AreEqual(CounterCount, results.Count); | ||
|
|
||
| foreach (var result in results) | ||
| { | ||
| var value = result.Item2; | ||
|
|
||
| Assert.AreEqual(categoryName, result.Item1.PerformanceCounter.CategoryName); | ||
| Assert.AreEqual(counterName, result.Item1.PerformanceCounter.CounterName); | ||
|
|
||
| if (instanceName != null) | ||
| { | ||
| Assert.AreEqual(instanceName, result.Item1.PerformanceCounter.InstanceName); | ||
| } | ||
|
|
||
| Assert.IsTrue(value >= 0 && value <= 100, "actual value:" + value + ". Should be 0-100"); | ||
| } | ||
| } | ||
|
|
||
| internal void PerformanceCollectorAddRemoveCountersForXPlatformTest(PerformanceCollectorXPlatform collector) | ||
| { | ||
| var counterRequests = new[] | ||
| { | ||
| new PerformanceCounterCollectionRequest(@"\Process(??APP_WIN32_PROC??)\Private Bytes", @"\Process(??APP_WIN32_PROC??)\Private Bytes"), | ||
| new PerformanceCounterCollectionRequest(@"\Process(??APP_WIN32_PROC??)\% Processor Time", @"\Process(??APP_WIN32_PROC??)\% Processor Time") | ||
| }; | ||
|
|
||
| foreach (var counterRequest in counterRequests) | ||
| { | ||
| string error; | ||
| collector.RegisterCounter( | ||
| counterRequest.PerformanceCounter, | ||
| counterRequest.ReportAs, | ||
| out error, | ||
| false); | ||
| } | ||
|
|
||
| var twoCounters = collector.PerformanceCounters.ToArray(); | ||
|
|
||
| collector.RemoveCounter( | ||
| @"\Process(??APP_WIN32_PROC??)\Private Bytes", | ||
| counterRequests[0].ReportAs); | ||
|
|
||
| var oneCounter = collector.PerformanceCounters.ToArray(); | ||
|
|
||
| Assert.AreEqual(2, twoCounters.Count()); | ||
| Assert.AreEqual(@"\Process(??APP_WIN32_PROC??)\Private Bytes", twoCounters[0].OriginalString); | ||
| Assert.AreEqual(@"\Process(??APP_WIN32_PROC??)\% Processor Time", twoCounters[1].OriginalString); | ||
|
|
||
| Assert.AreEqual(@"\Process(??APP_WIN32_PROC??)\% Processor Time", oneCounter.Single().OriginalString); | ||
| } | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
...manceCollector/NetCore20.Tests/Perf-NetCore20.Tests/PerformanceCollectorXPlatformTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| namespace Microsoft.ApplicationInsights.Tests | ||
| { | ||
| using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation; | ||
| using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.XPlatform; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| /// <summary> | ||
| /// WebAppPerformanceCollector tests. | ||
| /// </summary> | ||
| [TestClass] | ||
| public class PerformanceCollectorXPlatformTests : PerformanceCollectorXPlatformTestBase | ||
| { | ||
| [TestMethod] | ||
| public void PerformanceCollectorSanityTest() | ||
| { | ||
| this.PerformanceCollectorSanityTest(new PerformanceCollectorXPlatform(), @"\Process(??APP_WIN32_PROC??)\% Processor Time Normalized", "Process", @"% Processor Time Normalized", null); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void PerformanceCollectorAddRemoveCountersForXPlatformTest() | ||
| { | ||
| this.PerformanceCollectorAddRemoveCountersForXPlatformTest(new PerformanceCollectorXPlatform()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Src/PerformanceCollector/Perf.NetFull.Tests/StandardPerformanceCollectorTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="Microsoft.ApplicationInsights" version="2.10.0" targetFramework="net45" /> | ||
| <package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net45" /> | ||
| <package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net45" developmentDependency="true" /> | ||
| <package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net45" /> | ||
| </packages> | ||
| </packages> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.