diff --git a/Vostok.Metrics.System/Host/HostMetricsCollector.cs b/Vostok.Metrics.System/Host/HostMetricsCollector.cs index 52b719e..a0cc54a 100644 --- a/Vostok.Metrics.System/Host/HostMetricsCollector.cs +++ b/Vostok.Metrics.System/Host/HostMetricsCollector.cs @@ -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; diff --git a/Vostok.Metrics.System/Host/Legacy/LegacyHostCpuUtilizationCollector.cs b/Vostok.Metrics.System/Host/Legacy/LegacyHostCpuUtilizationCollector.cs index cc7abaf..1b34fec 100644 --- a/Vostok.Metrics.System/Host/Legacy/LegacyHostCpuUtilizationCollector.cs +++ b/Vostok.Metrics.System/Host/Legacy/LegacyHostCpuUtilizationCollector.cs @@ -3,6 +3,7 @@ namespace Vostok.Metrics.System.Host.Legacy { + [Obsolete] internal class LegacyHostCpuUtilizationCollector { private readonly Func coresCountProvider; diff --git a/Vostok.Metrics.System/Process/CurrentProcessMetricsCollector.cs b/Vostok.Metrics.System/Process/CurrentProcessMetricsCollector.cs index 0e77833..a4c3030 100644 --- a/Vostok.Metrics.System/Process/CurrentProcessMetricsCollector.cs +++ b/Vostok.Metrics.System/Process/CurrentProcessMetricsCollector.cs @@ -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; diff --git a/Vostok.Metrics.System/Process/INativeProcessMetricsCollector_Linux.cs b/Vostok.Metrics.System/Process/INativeProcessMetricsCollector_Linux.cs index bc54941..12c2fb6 100644 --- a/Vostok.Metrics.System/Process/INativeProcessMetricsCollector_Linux.cs +++ b/Vostok.Metrics.System/Process/INativeProcessMetricsCollector_Linux.cs @@ -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(); } \ No newline at end of file diff --git a/Vostok.Metrics.System/Process/Legacy/LegacyCurrentProcessCpuUtilizationCollector.cs b/Vostok.Metrics.System/Process/Legacy/LegacyCurrentProcessCpuUtilizationCollector.cs index 39624ef..8cbdf4d 100644 --- a/Vostok.Metrics.System/Process/Legacy/LegacyCurrentProcessCpuUtilizationCollector.cs +++ b/Vostok.Metrics.System/Process/Legacy/LegacyCurrentProcessCpuUtilizationCollector.cs @@ -3,6 +3,7 @@ namespace Vostok.Metrics.System.Process.Legacy { + [Obsolete] internal class LegacyCpuUtilizationCollector { private static readonly int DefaultCoresCount = Environment.ProcessorCount; diff --git a/Vostok.Metrics.System/Process/Legacy/LegacyNativeProcessMetricsCollector_Linux.cs b/Vostok.Metrics.System/Process/Legacy/LegacyNativeProcessMetricsCollector_Linux.cs index bcb52d4..aea23d1 100644 --- a/Vostok.Metrics.System/Process/Legacy/LegacyNativeProcessMetricsCollector_Linux.cs +++ b/Vostok.Metrics.System/Process/Legacy/LegacyNativeProcessMetricsCollector_Linux.cs @@ -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";