/** * Conflates the passed metric value into this one * * @param metricValue The metric value to conflate into this metric value */ public synchronized void conflate(ICEMetricValue metricValue) { if (!type.isLong() || !metricValue.type.isLong()) { StringBuilder b = new StringBuilder("Cannot conflate non-numeric values."); b.append("\n\tThis metric:").append(this.toString()); b.append("\n\tThat value:").append(metricValue); throw new RuntimeException(b.toString(), new Throwable()); } if (type != metricValue.type) { StringBuilder b = new StringBuilder("Cannot conflate values of different types."); b.append("\n\tThis metric:").append(this.toString()); b.append("\n\tThat value:").append(metricValue); throw new RuntimeException(b.toString(), new Throwable()); } if (type.isGauge()) { this.longValue = avg(2, this.longValue + metricValue.longValue); } else { this.longValue += metricValue.longValue; } }
/** * Returns the value as a long, or throws a RuntimeException if the type is not long based * * @return the long value */ public long getLongValue() { if (!type.isLong()) throw new RuntimeException("This value is not a long type", new Throwable()); return longValue; }