public static IDisposable Gauge(
     this IMetricScope scope,
     string name,
     Func <double> getValue)
 {
     return(scope.Gauge(MetricClock.DefaultPeriod, name, getValue));
 }
Ejemplo n.º 2
0
 public ProcessorHost(string consumerGroupHostId, string routingKey, IAirlockEventProcessor processor, ILog log, Consumer <Null, byte[]> consumer, IMetricScope metricScope, TimeSpan flushMetricsInterval, ProcessorHostSettings processorHostSettings)
 {
     this.routingKey            = routingKey;
     this.processor             = processor;
     this.log                   = log;
     this.consumer              = consumer;
     this.processorHostSettings = processorHostSettings;
     AssignedPartitions         = new int[0];
     processorThread            = new Thread(ProcessorThreadFunc)
     {
         IsBackground = true,
         Name         = $"processor-{consumerGroupHostId}-{processor.ProcessorId}",
     };
     queueGauge             = metricScope.Gauge(flushMetricsInterval, "queue_size", () => eventsQueue.Count);
     pausedGauge            = metricScope.Gauge(flushMetricsInterval, "paused", () => pausedPartitions != null ? 1 : 0);
     messageEnqueuedCounter = metricScope.Counter(flushMetricsInterval, "message_enqueued");
     processorMetrics       = new ProcessorMetrics(metricScope, flushMetricsInterval);
 }
Ejemplo n.º 3
0
        public static void Uptime(
            this IMetricScope scope,
            TimeSpan period)
        {
            var startTimestamp = DateTimeOffset.UtcNow;

            scope.Gauge(
                period,
                "uptime",
                () => (DateTimeOffset.UtcNow - startTimestamp).TotalMilliseconds);
        }
Ejemplo n.º 4
0
        public static void CpuLoad(
            this IMetricScope scope,
            TimeSpan period)
        {
            var cpuUsage = new CpuUsageMeter();

            scope.Gauge(period, "cpu", () =>
            {
                var processUsage = cpuUsage.Reset().ProcessUsage;
                return(processUsage);
            });
        }