示例#1
0
 public Task StartAsync(CancellationToken cancellationToken)
 {
     consecutiveLicenseCheckFailures.Set(0);
     remainingConsecutiveLicenseCheckFailures.Set(maxConsecutiveCheckFailures);
     periodicLicenseChecks = Task.Run(PeriodicLicenseChecksAsync);
     return(Task.CompletedTask);
 }
示例#2
0
 public void Set_Int64()
 {
     for (var i = 0; i < _opIterations; i++)
     {
         _gaugeInt64.Set(i);
     }
 }
        public void UpdateMetrics()
        {
            try
            {
                _process.Refresh();
                for (int generation = 0; generation < _collectionCounts.Count; generation++)
                {
                    var prevCount    = _gcCollectCounts[generation];
                    var currentCount = GC.CollectionCount(generation);
                    _gcCollectCounts[generation] = currentCount;
                    _collectionCounts[generation].Inc(currentCount - prevCount);
                }

                _totalMemory.Set(GC.GetTotalMemory(false));
                _virtualMemorySize.Set(_process.VirtualMemorySize64);
                _workingSet.Set(_process.WorkingSet64);
                _privateMemorySize.Set(_process.PrivateMemorySize64);
                _cpuTotal.Inc(Math.Max(0.0, _process.TotalProcessorTime.TotalSeconds - _cpuTotal.Value));
                _openHandles.Set(_process.HandleCount);
                _numThreads.Set(_process.Threads.Count);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }
        }
示例#4
0
 public void Set()
 {
     for (var i = 0; i < _opIterations; i++)
     {
         _gauge.Set(i);
     }
 }
        public void RegisterMetrics(ICollectorRegistry registry)
        {
            MetricFactory metricFactory = Prometheus.Metrics.WithCustomRegistry(registry);
            var           counter       = metricFactory.CreateCounter("gc_collect_count", "GC collection count",
                                                                      _lableNames.Union(new[] { "generation" }).ToArray());

            for (var number = 0; number <= GC.MaxGeneration; number++)
            {
                _collectionCounts.Add(counter.Labels(_labelValues.Union(new[] { number.ToString() }).ToArray()));
            }

            _startTime = metricFactory
                         .CreateGauge("start_time", "Start time of the process since unix epoch in seconds", _lableNames)
                         .Labels(_labelValues);
            _cpuTotal = metricFactory.CreateCounter("cpu_seconds_total",
                                                    "Total user and system CPU time spent in seconds", _lableNames).Labels(_labelValues);
            _virtualMemorySize = metricFactory.CreateGauge("virtual_bytes", "Process virtual memory size", _lableNames).Labels(_labelValues);
            _workingSet        = metricFactory.CreateGauge("working_set", "Process working set", _lableNames).Labels(_labelValues);
            _privateMemorySize = metricFactory.CreateGauge("private_bytes", "Process private memory size", _lableNames).Labels(_labelValues);
            _openHandles       = metricFactory.CreateGauge("open_handles", "Number of open handles", _lableNames).Labels(_labelValues);
            _numThreads        = metricFactory.CreateGauge("num_threads", "Total number of threads", _lableNames).Labels(_labelValues);
            _pid         = metricFactory.CreateGauge("processid", "Process ID", _lableNames).Labels(_labelValues);
            _totalMemory = metricFactory.CreateGauge("totalmemory", "Total known allocated memory", _lableNames).Labels(_labelValues);
            _startTime.Set((_process.StartTime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))
                           .TotalSeconds);
            _pid.Set(_process.Id);
        }
示例#6
0
        /// <summary>
        /// Sets the value of the gauge to the current Unix timestamp in seconds.
        /// </summary>
        public static void SetToCurrentTime(this IGauge gauge)
        {
            var unixTicks = DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks;

            // Convert to double first to ensure that we can report fractional seconds.
            gauge.Set((double)unixTicks / TimeSpan.TicksPerSecond);
        }
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            var count = await service.GetHostNumberOfEntriesAsync().ConfigureAwait(false);

            _numberOfHostsGauge.Set(count);
        }
示例#8
0
        private const long UnixEpochSeconds = UnixEpochTicks / TimeSpan.TicksPerSecond;                                     // 62,135,596,800

        /// <summary>
        /// Sets the value of the gauge to the current UTC time as a Unix timestamp in seconds.
        /// Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
        /// </summary>
        public static void SetToCurrentTimeUtc(this IGauge gauge)
        {
            // This gets us sub-millisecond precision, which is better than ToUnixTimeMilliseconds().
            var ticksSinceUnixEpoch   = DateTimeOffset.UtcNow.Ticks - UnixEpochSeconds * TimeSpan.TicksPerSecond;
            var secondsSinceUnixEpoch = ticksSinceUnixEpoch / (double)TimeSpan.TicksPerSecond;

            gauge.Set(secondsSinceUnixEpoch);
        }
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            var deviceInfo = await service.GetDeviceInfoAsync().ConfigureAwait(false);

            _uptimeGauge.Set(deviceInfo.UpTime);
        }
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            _totalBytesReceivedGauge.Set(await service.GetTotalBytesReceivedAsync().ConfigureAwait(false));
            _totalBytesSentGauge.Set(await service.GetTotalBytesSentAsync().ConfigureAwait(false));

            _totalPackagesReceivedGauge.Set(await service.GetTotalPacketsReceivedAsync().ConfigureAwait(false));
            _totalPackagesSentGauge.Set(await service.GetTotalPacketsSentAsync().ConfigureAwait(false));
        }
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            var stat = await service.GetStatisticsAsync().ConfigureAwait(false);

            _totalPackagesReceivedGauge.Set(stat.TotalPacketsReceived);
            _totalPackagesSentGauge.Set(stat.TotalPacketsSent);


            _totalConnectionsGauge.Set(await service.GetTotalAssociationsAsync().ConfigureAwait(false));
        }
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            var info = await service.GetInfoAsync().ConfigureAwait(false);

            _maxBitrageGauge.Set(info.MaxBitRate);
            _lanEnabledGauge.Set(info.Enable ? 1 : 0);

            var statistics = await service.GetStatisticsAsync().ConfigureAwait(false);

            _bytesSentGauge.Set(statistics.BytesSent);
            _bytesReceivedGauge.Set(statistics.BytesReceived);
            _packagesSentGauge.Set(statistics.PacketsSent);
            _packagesReceivedGauge.Set(statistics.PacketsReceived);
        }
示例#13
0
        public async Task CollectAsync()
        {
            var service = await _client.Get().ConfigureAwait(false);

            var info = await service.GetInfoAsync().ConfigureAwait(false);

            _EnabledGauge.Set(info.Enabled ? 1 : 0);
            _DownstreamAttenuationGauge.Set(info.DownstreamAttenuation);
            _UpstreamAttenuationGauge.Set(info.UpstreamAttenuation);
            _DownstreamCurrentRateGauge.Set(info.DownstreamCurrentRate);
            _DownstreamMaxRateGauge.Set(info.DownstreamMaxRate);
            _DownstreamNoiseMarginGauge.Set(info.DownstreamNoiseMargin);
            _DownstreamPowerGauge.Set(info.DownstreamPower);
            _UpstreamCurrentRateGauge.Set(info.UpstreamCurrentRate);
            _UpstreamMaxRateGauge.Set(info.UpstreamMaxRate);
            _UpstreamNoiseMarginGauge.Set(info.UpstreamNoiseMargin);
            _UpstreamPowerGauge.Set(info.UpstreamPower);

            var stats = await service.GetStatisticsTotalAsync().ConfigureAwait(false);

            _ATUCCRCErrorsGauge.Set(stats.ATUCCRCErrors);
            _ATUCFECErrorsGauge.Set(stats.ATUCFECErrors);
            _ATUCHECErrorsGauge.Set(stats.ATUCHECErrors);
            _CellDelinGauge.Set(stats.CellDelin);
            _CRCErrorsGauge.Set(stats.CRCErrors);
            _ErroredSecsGauge.Set(stats.ErroredSecs);
            _FECErrorsGauge.Set(stats.FECErrors);
            _HECErrorsGauge.Set(stats.HECErrors);
            _InitErrorsGauge.Set(stats.InitErrors);
            _InitTimeoutsGauge.Set(stats.InitTimeouts);
            _LinkRetrainGauge.Set(stats.LinkRetrain);
            _LossOfFramingGauge.Set(stats.LossOfFraming);
            _ReceiveBlocksGauge.Set(stats.ReceiveBlocks);
            _SeverelyErroredSecsGauge.Set(stats.SeverelyErroredSecs);
            _TransmitBlocksGauge.Set(stats.TransmitBlocks);
        }
示例#14
0
 public void ApplyDuration()
 {
     _gauge.Set(_stopwatch.Elapsed.TotalSeconds);
 }
示例#15
0
 public Timer(IGauge gauge)
 {
     _observeDurationAction = duration => gauge.Set(duration);
 }
 public Timer(IGauge gauge)
 {
     _observeDurationAction = () => gauge.Set(_stopwatch.Elapsed.TotalSeconds);
     _stopwatch             = Stopwatch.StartNew();
 }
示例#17
0
 public Timer(IGauge gauge)
 {
     _reportDurationAction = () => gauge.Set(_stopwatch.Elapsed.TotalSeconds);
     _stopwatch            = System.Diagnostics.Stopwatch.StartNew();
 }
示例#18
0
        private const long UnixEpochSeconds = UnixEpochTicks / TimeSpan.TicksPerSecond;                                     // 62,135,596,800

        /// <summary>
        /// Sets the value of the gauge to the current UTC time as a Unix timestamp in seconds.
        /// Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
        /// </summary>
        public static void SetToCurrentTimeUtc(this IGauge gauge)
        {
            gauge.Set(ToUnixTimeSecondsAsDouble(DateTimeOffset.UtcNow));
        }
示例#19
0
 public static void Set(this IGauge gauge, double val, DateTimeOffset timestamp)
 {
     gauge.Set(val, timestamp.ToUnixTime());
 }
 public static void Set(this IGauge <long> gauge, long val, DateTimeOffset timestamp)
 {
     gauge.Set(val, timestamp.ToUnixTimeMilliseconds());
 }
示例#21
0
 /// <summary>
 /// Sets the value of the gauge to a specific moment as the UTC timezone Unix timestamp in seconds.
 /// Value does not include any elapsed leap seconds because Unix timestamps do not include leap seconds.
 /// </summary>
 public static void SetToTimeUtc(this IGauge gauge, DateTimeOffset timestamp)
 {
     gauge.Set(ToUnixTimeSecondsAsDouble(timestamp));
 }