@Test
  public void testHistogramMetric() {

    List<String> keys = new ArrayList<>();
    List<String> values = new ArrayList<>();

    for (int i = 0; i < 300; i++) {
      keys.add(getRandomString());
      values.add(getRandomString());
    }

    for (int i = 0; i < keys.size(); i++) {
      store.put(keys.get(i), values.get(i));
    }

    Set<String> names = new HashSet<>();
    for (Double p : serializedKeyValueStoreMetrics.record_key_size_percentiles()) {
      names.add(storeName + "-" + keyPrefix + "_" + p);
    }

    for (Double p : serializedKeyValueStoreMetrics.record_value_size_percentiles()) {
      names.add(storeName + "-" + valuePrefix + "_" + p);
    }

    metricsRegistry.getGroups().forEach(group -> metricsRegistry.getGroup(group.toString()).forEach((name, metric) -> {
      if (names.contains(name)) {
        metric.visit(new MetricsVisitor() {
          @Override
          public void counter(Counter counter) {

          }

          @Override
          public <T> void gauge(Gauge<T> gauge) {
            Double num = (Double) gauge.getValue();
            Assert.assertNotEquals(0D, (Double) gauge.getValue(), 0.0001);
          }

          @Override
          public void timer(Timer timer) {

          }
        });
      }
    }));
  }
Make sure that the histograms can record the key value size and we can use a
{@link MetricsVisitor} to get access to the value store in the histograms
samza-test/src/test/java/org/apache/samza/storage/kv/TestKeyValueSizeHistogramMetric.java