Skip to content

Commit

Permalink
Adapt GcMetricsProvider to work on .NET5 (#1026)
Browse files Browse the repository at this point in the history
From #1006
  • Loading branch information
gregkalapos authored Nov 11, 2020
1 parent 9f6dd86 commit 5a626ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Elastic.Apm/Metrics/MetricsProvider/GcMetricsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public GcMetricsProvider(IApmLogger logger, bool collectGcCount = true, bool col
}
}

if (PlatformDetection.IsDotNetCore)
if (PlatformDetection.IsDotNetCore || PlatformDetection.IsDotNet5)
_eventListener = new GcEventListener(this, logger);
}

Expand All @@ -141,7 +141,7 @@ public IEnumerable<MetricSample> GetSamples()
{
if (_gcCount != 0 || _gen0Size != 0 || _gen2Size != 0 || _gen3Size != 0)
{
var retVal = new List<MetricSample>();
var retVal = new List<MetricSample>(5);

if (_collectGcCount)
retVal.Add(new MetricSample(GcCountName, _gcCount));
Expand Down
2 changes: 1 addition & 1 deletion test/Elastic.Apm.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void ReadServerUrlsWithSpaceAtTheEndViaEnvironmentVariable()
var payloadSender = new MockPayloadSender();
using (var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender, config: new EnvironmentConfigurationReader())))
{
#if !NETCOREAPP3_0 && !NETCOREAPP3_1
#if !NETCOREAPP3_0 && !NETCOREAPP3_1 && !NET5_0
agent.ConfigurationReader.ServerUrls.First().Should().NotBe(serverUrlsWithSpace);
#endif
agent.ConfigurationReader.ServerUrls.First().Should().Be("http://myServer:1234");
Expand Down
2 changes: 1 addition & 1 deletion test/Elastic.Apm.Tests/MetricsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void CollectGcMetrics()
}
}

if (PlatformDetection.IsDotNetCore)
if (PlatformDetection.IsDotNetCore || PlatformDetection.IsDotNet5)
{
if (!logger.Lines.Where(n => n.Contains("OnEventWritten with GC")).Any())
{
Expand Down

0 comments on commit 5a626ac

Please sign in to comment.