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(); }); } }
public ManualTimerMetric( TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear) : base(durationUnit, rateUnit, meter, histogram, clear) { }
protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear) { DurationUnit = durationUnit; RateUnit = rateUnit; _meter = meter; _histogram = histogram; if(clear) { Clear(); } }
protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear) { DurationUnit = durationUnit; RateUnit = rateUnit; _meter = meter; _histogram = histogram; if (clear) { Clear(); } }
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); }
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; }
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), }; }
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; }
public TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit) : this(durationUnit, rateUnit, MeterMetric.New("calls", rateUnit), new HistogramMetric(HistogramMetric.SampleType.Biased), true /* clear */) { }
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)); }