public MetricValue getMetricValue() { return new CounterMetricValue(range, count); } }
public int compareTo(CounterMetricValue o) { return getTimeStamp().compareTo(o.getTimeStamp()); }
public CounterMetricValue aggregateValues(TimeRange range, Collection<CounterMetricValue> values) { double total = 0; for (CounterMetricValue value : values) { total += value.getCount(); } return new CounterMetricValue(range, total); } }
public void allocateWeighted(List<MutableCounterMetricValue> targets) { if (isEmpty()) { return; } double value=getValue(); TimeRange timeRange=getRange(); for (MutableCounterMetricValue target: targets) { TimeRange targetRange=target.getRange(); double factor=timeRange.percentageWithin(targetRange); target.increment(value * factor); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CounterMetricValue other = (CounterMetricValue) obj; return (Double.doubleToLongBits(getCount()) == Double.doubleToLongBits(other.getCount())) && ObjectUtil.typedEquals(getRange(), other.getRange()) ; }
public boolean isEmpty() { return getValue() == 0.0d; }
public double getValueRepresenting(TimeRange range) { return getRollupValue(range).getCount(); }
@Override protected void setValueForSlot(int slot, CounterMetricValue val) { slots[slot] = val.getValue(); }
public CounterMetricValue createEmptyValue(TimeRange range) { return new CounterMetricValue(range, 0); }
public CounterMetricValue build() { return new CounterMetricValue(valueRange, count); } }
public CounterMetricValue getCounterMetricValue() { if (counter != null) { return counter; } counter = new CounterMetricValue(getTimeRange(), value); return counter; }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { if (!analysis.isError()) { return Collections.emptyList(); } ResourceMetricKey rmKey = ResourceMetricKey.valueOf(analysis.getEndPoint().getKey(), ERROR_COUNT); CounterMetricValue val = new CounterMetricValue(analysis.getResponseTime(), 1); return Collections.singletonList(new UpdateMetricCommand(rmKey, val)); }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { List<MetricKey> tagMetricKeys = getMetricsForTags(analysis.getTraceTags()); List<UpdateMetricCommand> commands = new ArrayList<UpdateMetricCommand>(tagMetricKeys.size()); TimeRange responseTime = analysis.getResponseTime(); ResourceKey resourceKey = analysis.getEndPoint().getKey(); for (MetricKey tagMetricKey : tagMetricKeys) { ResourceMetricKey rmKey = ResourceMetricKey.valueOf(resourceKey, tagMetricKey); CounterMetricValue value = new CounterMetricValue(responseTime, 1); commands.add(new UpdateMetricCommand(rmKey, value)); } return commands; }
public List<UpdateMetricCommand> generateCommands(TraceAnalysis analysis) { Resource endPoint=analysis.getEndPoint(); ResourceMetricKey rmKey=ResourceMetricKey.valueOf(endPoint.getKey(), INVOCATION_COUNT); CounterMetricValue value=new CounterMetricValue(analysis.getResponseTime(), 1.0d); return singletonList(new UpdateMetricCommand(rmKey, value)); } }
public List<CounterMetricValue> calculateSortedSegmentedPoints(List<IDataPoint> sortedPoints, Granularity gran) { List<CounterMetricValue> metrics = new ArrayList<CounterMetricValue>(); IDataPoint startPt = sortedPoints.get(0); long startTime = startPt.getTimeStamp().alignDownToGranularity(gran).getNanos(); long endTime = startTime + gran.getNanos(); long count = 0; for (IDataPoint pt : sortedPoints) { long ptNanos = pt.getTimeStamp().getNanos(); if (ptNanos >= endTime) { CounterMetricValue metric = new CounterMetricValue(TimeRange.nanoTimeRange(startTime, endTime), count); metrics.add(metric); while (ptNanos >= endTime) { startTime = endTime; endTime += gran.getNanos(); } count = 0; } count += pt.getValue(); } metrics.add(new CounterMetricValue(TimeRange.nanoTimeRange(startTime, endTime), count)); return metrics; }
@Override CounterMetricValue getValueForSlot(int slot, Time slotStartTime) { double count = slots[slot]; return new CounterMetricValue( TimeRange.nanoTimeRange(slotStartTime.getNanos(), slotStartTime.getNanos() + getEntryGranularity().getNanos()), count); }
public static UpdateMetricCommand getIncrementCommand() { ResourceMetricKey key = ResourceMetricKey.valueOf(getServerResourceCommand("butter", "butter-label").getResource().getKey(), Metrics.INVOCATION_COUNT); CounterMetricValue counter = new CounterMetricValue(TimeRange.range(0, 56), 56.0); return new UpdateMetricCommand(key, counter); }