@Override protected Number map_(MetricValue x) { final Optional<Number> hist_count = x.histogram().map(Histogram::getEventCount); return hist_count.orElse(x.isPresent() ? 1L : 0L); } @Override
public Entry(@NonNull String tagName, @NonNull MetricValue tagValue) { if (tagName.isEmpty()) throw new IllegalArgumentException("tag with empty name"); if (!tagValue.isPresent()) throw new IllegalArgumentException("tag with absent metric value"); if (tagValue.histogram().isPresent()) throw new IllegalArgumentException("tag with histogram makes no sense"); this.tagName = tagName; this.tagValue = tagValue; } }
public Entry(@NonNull String tagName, @NonNull MetricValue tagValue) { if (tagName.isEmpty()) throw new IllegalArgumentException("tag with empty name"); if (!tagValue.isPresent()) throw new IllegalArgumentException("tag with absent metric value"); if (tagValue.histogram().isPresent()) throw new IllegalArgumentException("tag with histogram makes no sense"); this.tagName = tagName; this.tagValue = tagValue; } }
@Override protected Optional<Number> map_(MetricValue x) { if (!x.isPresent()) return Optional.of(0L); final Optional<Number> hist_count = x.histogram().map(Histogram::sum); return hist_count.isPresent() ? hist_count : x.value(); } @Override