A meter metric which measures mean throughput and one-, five-, and fifteen-minute exponentially-weighted moving average throughputs.
Inheritance: IMetric, IMetered, IDisposable
Exemplo n.º 1
0
        public PrefetchingBehavior(PrefetchingUser prefetchingUser, 
            WorkContext context, 
            BaseBatchSizeAutoTuner autoTuner, 
            string prefetchingUserDescription, 
            bool isDefault = false,
            Func<int> getPrefetchintBehavioursCount = null,
            Func<PrefetchingSummary> getPrefetcherSummary = null)
        {
            this.context = context;
            this.autoTuner = autoTuner;
            PrefetchingUser = prefetchingUser;
            this.userDescription = prefetchingUserDescription;
            this.IsDefault = isDefault;
            this.getPrefetchintBehavioursCount = getPrefetchintBehavioursCount ?? (() => 1);
            this.getPrefetcherSummary = getPrefetcherSummary ?? GetSummary;
            MemoryStatistics.RegisterLowMemoryHandler(this);
            LastTimeUsed = DateTime.MinValue;

            ingestMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                "ingest/sec", "In memory documents held by this prefetcher", TimeUnit.Seconds);
            returnedDocsMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                  "returned docs/sec", "Documents being served by this prefetcher", TimeUnit.Seconds);

            if (isDefault)
            {
                context.Database.TransactionalStorage.Batch(accessor =>
                {
                    recentEtag = accessor.Staleness.GetMostRecentDocumentEtag();
                });
            }
        }
Exemplo n.º 2
0
 public ManualTimerMetric(
  TimeUnit durationUnit, 
  TimeUnit rateUnit, 
  MeterMetric meter, 
  HistogramMetric histogram, 
  bool clear)
     : base(durationUnit, rateUnit, meter, histogram, clear)
 {
 }
Exemplo n.º 3
0
 public ManualTimerMetric(
     TimeUnit durationUnit,
     TimeUnit rateUnit,
     MeterMetric meter,
     HistogramMetric histogram,
     bool clear)
     : base(durationUnit, rateUnit, meter, histogram, clear)
 {
 }
Exemplo n.º 4
0
 protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear)
 {
     DurationUnit = durationUnit;
      RateUnit = rateUnit;
      _meter = meter;
      _histogram = histogram;
      if(clear)
      {
     Clear();
      }
 }
Exemplo n.º 5
0
 protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear)
 {
     DurationUnit = durationUnit;
     RateUnit     = rateUnit;
     _meter       = meter;
     _histogram   = histogram;
     if (clear)
     {
         Clear();
     }
 }
Exemplo n.º 6
0
        public static MeterMetric New(string eventType, TimeUnit rateUnit)
        {
            var meter = new MeterMetric(eventType, rateUnit);

            Task.Factory.StartNew(async() =>
            {
                while (!meter._token.IsCancellationRequested)
                {
                    await Task.Delay(Interval, meter._token.Token);
                    meter.Tick();
                }
            }, meter._token.Token);
            return(meter);
        }
Exemplo n.º 7
0
        public static MeterMetric New(string eventType, TimeUnit rateUnit)
        {
            var meter = new MeterMetric(eventType, rateUnit);

            Task.Factory.StartNew(() =>
            {
                while (!meter._token.IsCancellationRequested)
                {
                    Thread.Sleep(Interval);
                    meter.Tick();
                }
            }, meter._token.Token);

            return meter;
        }
Exemplo n.º 8
0
 private static MeterData CreateMeterData(MeterMetric metric)
 {
     return new MeterData
            {
                Count = metric.Count,
                FifteenMinuteRate = Math.Round(metric.FifteenMinuteRate, 3),
                FiveMinuteRate = Math.Round(metric.FiveMinuteRate, 3),
                MeanRate = Math.Round(metric.MeanRate, 3),
                OneMinuteRate = Math.Round(metric.OneMinuteRate, 3),
            };
 }
Exemplo n.º 9
0
        public static MeterMetric New(string eventType, TimeUnit rateUnit)
        {
            var meter = new MeterMetric(eventType, rateUnit);

            meter._tickThread = _factory.New(
                ()=>
                    {
                        new Timer(s => meter.Tick(), null, _interval, _interval);
                    }
                );

            meter._tickThread.Start();

            return meter;
        }
Exemplo n.º 10
0
 public TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit)
     : this(durationUnit, rateUnit, MeterMetric.New("calls", rateUnit), new HistogramMetric(HistogramMetric.SampleType.Biased), true /* clear */)
 {
 }
Exemplo n.º 11
0
        public static MeterMetric New(string eventType, TimeUnit rateUnit)
        {
            var meter = new MeterMetric(eventType, rateUnit);

            meter._token = Utils.StartCancellableTask(() =>
            {
                while (!meter._token.IsCancellationRequested)
                {
                    Thread.Sleep(Interval);
                    meter.Tick();
                }
            });

            return meter;
        }
 private void LogMeter(IRequest request, MetricName metricName, MeterMetric metric, long timestamp)
 {
     request.AddCounter(new DatadogCounter(_nameFormatter.Format(metricName.Name, _path), metric.Count, timestamp, _globalTags));
 }