public static MetricsReporter combine(MetricsReporter first, MetricsReporter second) {
    if (null == first) {
      return second;
    } else if (null == second || first == second) {
      return first;
    }

    Set<MetricsReporter> reporters = Sets.newIdentityHashSet();

    if (first instanceof CompositeMetricsReporter) {
      reporters.addAll(((CompositeMetricsReporter) first).reporters());
    } else {
      reporters.add(first);
    }

    if (second instanceof CompositeMetricsReporter) {
      reporters.addAll(((CompositeMetricsReporter) second).reporters());
    } else {
      reporters.add(second);
    }

    return new CompositeMetricsReporter(reporters);
  }
@Test
  public void reportWithMultipleMetricsReporters() {
    AtomicInteger counter = new AtomicInteger();
    MetricsReporter combined =
        MetricsReporters.combine(
            report -> counter.incrementAndGet(), report -> counter.incrementAndGet());

    combined.report(new MetricsReport() {});

    assertThat(combined).isInstanceOf(MetricsReporters.CompositeMetricsReporter.class);
    assertThat(((MetricsReporters.CompositeMetricsReporter) combined).reporters()).hasSize(2);
    assertThat(counter.get()).isEqualTo(2);
  }