public IActionResult GetMetricsByPercentileFromAgent( [FromRoute] int agentId, [FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime, [FromRoute] int percentile) { _logger.LogInformation($"GetMetricsByPercentileFromAgent:{agentId} from:{fromTime} to:{toTime} int:{percentile}"); var metrics = _repository.GetByTimePeriodSorted(agentId, fromTime, toTime); var response = new RamMetricsResponse() { Metrics = new List <RamMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map <RamMetricDto>(metric)); } int[] values = new int[response.Metrics.Count()]; for (int i = 0; i < response.Metrics.Count(); i++) { values[i] = response.Metrics[i].Value; } return(Ok(PercentileCounter.GetPercentile(values, percentile))); }
public PerformanceCounterAccessor(string instanceName) { this.counters = TaskDistributionFabricPerfCounters.GetInstance(instanceName); SlidingTotalCounter counter = new SlidingTotalCounter(PerformanceCounterAccessor.SlidingCounterInterval, PerformanceCounterAccessor.SlidingCounterPrecision); this.successfulRequests = new PerformanceCounterAccessor.PeriodicSlidingTotalCounter(PerformanceCounterAccessor.BatchDuration, counter); SlidingTotalCounter counter2 = new SlidingTotalCounter(PerformanceCounterAccessor.SlidingCounterInterval, PerformanceCounterAccessor.SlidingCounterPrecision); this.failedRequests = new PerformanceCounterAccessor.PeriodicSlidingTotalCounter(PerformanceCounterAccessor.BatchDuration, counter2); PercentileCounter counter3 = new PercentileCounter(PerformanceCounterAccessor.PercentileCounterInterval, PerformanceCounterAccessor.PercentileCounterPrecision, 1L, 1000L); this.queueLength = new PerformanceCounterAccessor.PeriodicPercentileCounter(PerformanceCounterAccessor.BatchDuration, counter3); PercentileCounter counter4 = new PercentileCounter(PerformanceCounterAccessor.PercentileCounterInterval, PerformanceCounterAccessor.PercentileCounterPrecision, 10L, 10000L); this.queueLatency = new PerformanceCounterAccessor.PeriodicPercentileCounter(PerformanceCounterAccessor.BatchDuration, counter4); PercentileCounter counter5 = new PercentileCounter(PerformanceCounterAccessor.PercentileCounterInterval, PerformanceCounterAccessor.PercentileCounterPrecision, 5L, 5000L); this.processorLatency = new PerformanceCounterAccessor.PeriodicPercentileCounter(PerformanceCounterAccessor.BatchDuration, counter5); }
public PeriodicPercentileCounter(TimeSpan batchDuration, PercentileCounter counter) { this.batchDuration = batchDuration; this.counter = counter; this.syncObj = new object(); }