/// <summary>
        /// Initializes a new instance of <see cref="CgroupMetricsProvider"/>
        /// </summary>
        /// <param name="procSelfCGroup">the <see cref="ProcSelfCgroup"/> file</param>
        /// <param name="mountInfo">the <see cref="ProcSelfMountinfo"/> file</param>
        /// <param name="logger">the logger</param>
        /// <param name="collectMemLimitBytes">whether to collect <see cref="SystemProcessCgroupMemoryMemLimitBytes"/> metric</param>
        /// <param name="collectMemUsageBytes">whether to collect <see cref="SystemProcessCgroupMemoryMemUsageBytes"/> metric</param>
        /// <param name="collectStatsInactiveFileBytes">whether to collect <see cref="SystemProcessCgroupMemoryStatsInactiveFileBytes"/> metric</param>
        /// <remarks>
        ///	Used for testing
        /// </remarks>
        internal CgroupMetricsProvider(string procSelfCGroup, string mountInfo, IApmLogger logger, bool collectMemLimitBytes = true, bool collectMemUsageBytes = true, bool collectStatsInactiveFileBytes = true)
        {
            _collectMemLimitBytes          = collectMemLimitBytes;
            _collectMemUsageBytes          = collectMemUsageBytes;
            _collectStatsInactiveFileBytes = collectStatsInactiveFileBytes;
            _logger      = logger.Scoped(nameof(CgroupMetricsProvider));
            _cGroupFiles = FindCGroupFiles(procSelfCGroup, mountInfo);

            IsMetricAlreadyCaptured = true;
        }
Example #2
0
        /// <summary>
        ///  Initializes a new instance of <see cref="CgroupMetricsProvider" />
        /// </summary>
        /// <param name="procSelfCGroup">the <see cref="ProcSelfCgroup" /> file</param>
        /// <param name="mountInfo">the <see cref="ProcSelfMountinfo" /> file</param>
        /// <param name="logger">the logger</param>
        /// <param name="disabledMetrics">List of disabled metrics</param>
        /// <remarks>
        ///     Used for testing
        /// </remarks>
        internal CgroupMetricsProvider(string procSelfCGroup, string mountInfo, IApmLogger logger, IReadOnlyList <WildcardMatcher> disabledMetrics
                                       )
        {
            _collectMemLimitBytes          = IsSystemProcessCgroupMemoryMemLimitBytesEnabled(disabledMetrics);
            _collectMemUsageBytes          = IsSystemProcessCgroupMemoryMemUsageBytesEnabled(disabledMetrics);
            _collectStatsInactiveFileBytes = IsSystemProcessCgroupMemoryStatsInactiveFileBytesEnabled(disabledMetrics);
            _logger      = logger.Scoped(nameof(CgroupMetricsProvider));
            _cGroupFiles = FindCGroupFiles(procSelfCGroup, mountInfo);

            IsMetricAlreadyCaptured = true;
        }