public GaugeMetricValue createEmptyValue(TimeRange range) { return new GaugeMetricValue(range); }
public MetricValue getMetricValue() { return new GaugeMetricValue(range, min, max, n, sum, sumOfSquares, histo.getSparseHistogram()); }
public void fromData(DataInput dataInput) throws IOException { super.fromData(serialVersionUID, dataInput); int numSlots = dataInput.readInt(); GaugeMetricValue[] slots = new GaugeMetricValue[numSlots]; int usedSlots = dataInput.readInt(); for (int i=0; i<usedSlots; i++) { int slotIdx = dataInput.readInt(); double min = dataInput.readDouble(); double max = dataInput.readDouble(); long n = dataInput.readLong(); double sum = dataInput.readDouble(); double sumOfSquares = dataInput.readDouble(); long rangeStart = dataInput.readLong(); long rangeEnd = rangeStart + getEntryGranularity().getNanos(); int numBins = dataInput.readInt(); List<IndexedBin> bins = new ArrayList<IndexedBin>(numBins); for (int b=0; b<numBins; b++) { bins.add(new IndexedBin(dataInput.readInt(), dataInput.readLong())); } slots[slotIdx] = new GaugeMetricValue(TimeRange.nanoTimeRange(rangeStart, rangeEnd), min, max, n, sum, sumOfSquares, new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), bins)); } this.slots = Arrays.asList(slots); }
public GaugeMetricValue build() { return new GaugeMetricValue(valueRange, stats.getMin(), stats.getMax(), stats.getN(), Double.isNaN(stats.getSum()) ? 0.0 : stats.getSum(), Double.isNaN(stats.getSumsq()) ? 0.0 : stats.getSumsq(), accum.getSparseHistogram()); } }
public static UpdateMetricDistributionCommand getUpdateGauge() { ResourceMetricKey key = ResourceMetricKey.valueOf(getServerResourceCommand("butter", "butter-label").getResource().getKey(), Metrics.ENDPOINT_RESPONSE_TIME); IndexedBin bin1 = new IndexedBin(1, 4); IndexedBin bin2 = new IndexedBin(2, 6); SparseHistogram histo = new SparseHistogram(InsightGaugeHistogramDefinition.getInstance(), Arrays.asList(bin1, bin2)); GaugeMetricValue gauge = new GaugeMetricValue(TimeRange.range(0, 56), 34, 80, 40, 400, 600,histo); return new UpdateMetricDistributionCommand(key, gauge); }
/** * Create a {@link GaugeMetricValue} from a series of {@link GaugeMetricValue}s. The * resulting value will be a summarization of each individual value. * * @param range The range which represents the aggregated value */ public GaugeMetricValue fromValues(TimeRange range, Collection<GaugeMetricValue> values) { if (values.isEmpty()) { return new GaugeMetricValue(range); } HistogramAccumulator accum = makeHistoAccumulator(); Min min = new Min(); Max max = new Max(); Sum total = new Sum(); Sum n = new Sum(); Sum sumOfSquares = new Sum(); for (GaugeMetricValue v : values) { min.increment(v.getMin()); max.increment(v.getMax()); n.increment(v.getN()); total.increment(v.getSum()); sumOfSquares.increment(v.getSumOfSquares()); accum.add(v.getHistogram()); } return new GaugeMetricValue(range, min.getResult(), max.getResult(), (long)n.getResult(), total.getResult(), sumOfSquares.getResult(), accum.getSparseHistogram()); }