-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Summary Added event sampling for high throughput stats collectors to reduce memory footprint, should hopefully resolve [issue #6](#6). # Changes - `JitStatsCollector`, `ThreadPoolSchedulingStatsCollector` and `ContentionStatsCollector` can now be configured to discard a ratio of start/ stop events, reducing the number of events we need to store in a `Cache` at any one time - A new default sampling rate has been configured for the above collectors (see README) - Updated README with example on how to configure sampling and details of the defaults for each stats collector
- Loading branch information
Showing
19 changed files
with
400 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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 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
1 change: 1 addition & 0 deletions
1
src/prometheus-net.DotNetRuntime.Tests/DotNetRuntimeStatsBuilderTests.cs
This file contains 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 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 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 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 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 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
48 changes: 48 additions & 0 deletions
48
src/prometheus-net.DotNetRuntime.Tests/StatsCollectors/Util/SamplingRateTests.cs
This file contains 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,48 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using Prometheus.DotNetRuntime.StatsCollectors.Util; | ||
|
||
namespace Prometheus.DotNetRuntime.Tests.StatsCollectors.Util | ||
{ | ||
[TestFixture] | ||
public class SamplingRateTests | ||
{ | ||
[Test] | ||
[TestCase(SampleEvery.OneEvent, 1)] | ||
[TestCase(SampleEvery.TwoEvents, 2)] | ||
[TestCase(SampleEvery.FiveEvents, 5)] | ||
[TestCase(SampleEvery.TenEvents, 10)] | ||
[TestCase(SampleEvery.TwentyEvents, 20)] | ||
[TestCase(SampleEvery.FiftyEvents, 50)] | ||
[TestCase(SampleEvery.HundredEvents, 100)] | ||
public void SampleEvery_Reflects_The_Ratio_Of_Every_100_Events_That_Will_Be_Sampled(SampleEvery samplingRate, int expected) | ||
{ | ||
var sr = new SamplingRate(samplingRate); | ||
Assert.That(sr.SampleEvery, Is.EqualTo(expected)); | ||
} | ||
|
||
[Test] | ||
[TestCase(SampleEvery.OneEvent, 1000)] | ||
[TestCase(SampleEvery.TwoEvents, 500)] | ||
[TestCase(SampleEvery.FiveEvents, 200)] | ||
[TestCase(SampleEvery.TenEvents, 100)] | ||
[TestCase(SampleEvery.TwentyEvents, 50)] | ||
[TestCase(SampleEvery.FiftyEvents, 20)] | ||
[TestCase(SampleEvery.HundredEvents, 10)] | ||
public void Given_1000_Events_ShouldSampleEvent_Returns_True_Every_Nth_Event(SampleEvery samplingRate, int expectedEvents) | ||
{ | ||
var eventsSampled = 0; | ||
var sr = new SamplingRate(samplingRate); | ||
|
||
for (int i = 0; i < 1_000; i++) | ||
{ | ||
if (sr.ShouldSampleEvent()) | ||
{ | ||
eventsSampled++; | ||
} | ||
} | ||
|
||
Assert.That(eventsSampled, Is.EqualTo(expectedEvents)); | ||
} | ||
} | ||
} |
Oops, something went wrong.