Skip to content

Commit

Permalink
cr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Roshchupkin committed Apr 5, 2024
1 parent 65609c7 commit e0b35b7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Vostok.Metrics.System/Host/HostMetricsCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ public HostMetricsCollector(HostMetricsSettings settings)

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var useLegacyCollector = Environment.GetEnvironmentVariable(VostokSystemMetricsConstants.UseLegacyMetricsCollectorEnvironmentVariable) == "TRUE";
var useLegacyCollector = Environment
.GetEnvironmentVariable(VostokSystemMetricsConstants.UseLegacyMetricsCollectorEnvironmentVariable)?
.Equals("true", StringComparison.InvariantCultureIgnoreCase) ?? false;
INativeHostMetricsCollector_Linux collector = useLegacyCollector
#pragma warning disable CS0612
? new LegacyNativeHostMetricsCollector_Linux(this.settings)
#pragma warning restore CS0612
: new NativeHostMetricsCollector_Linux(this.settings);
nativeCollector = collector.Collect;
disposeNativeCollector = collector.Dispose;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Vostok.Metrics.System.Host.Legacy
{
[Obsolete]
internal class LegacyHostCpuUtilizationCollector
{
private readonly Func<int?> coresCountProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ public CurrentProcessMetricsCollector(CurrentProcessMetricsSettings settings)

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var useLegacyCollector = Environment.GetEnvironmentVariable(VostokSystemMetricsConstants.UseLegacyMetricsCollectorEnvironmentVariable) == "TRUE";
var useLegacyCollector = Environment
.GetEnvironmentVariable(VostokSystemMetricsConstants.UseLegacyMetricsCollectorEnvironmentVariable)?
.Equals("true", StringComparison.InvariantCultureIgnoreCase) ?? false;
INativeProcessMetricsCollector_Linux collector = useLegacyCollector
#pragma warning disable CS0612
? new LegacyNativeMetricsCollector_Linux()
#pragma warning restore CS0612
: new NativeProcessMetricsCollector_Linux(this.settings.LinuxSettings);
nativeCollector = collector.Collect;
disposeNativeCollector = collector.Dispose;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;

namespace Vostok.Metrics.System.Process;

// ReSharper disable once InconsistentNaming
internal interface INativeProcessMetricsCollector_Linux
internal interface INativeProcessMetricsCollector_Linux : IDisposable
{
void Collect(CurrentProcessMetrics metrics);
void Dispose();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Vostok.Metrics.System.Process.Legacy
{
[Obsolete]
internal class LegacyCpuUtilizationCollector
{
private static readonly int DefaultCoresCount = Environment.ProcessorCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Vostok.Metrics.System.Process.Legacy
{
[Obsolete]
internal class LegacyNativeMetricsCollector_Linux : INativeProcessMetricsCollector_Linux
{
private const string cgroupMemoryLimitFileName = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
Expand Down

0 comments on commit e0b35b7

Please sign in to comment.