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 combineWithNullReporter() {
    MetricsReporter reporter = report -> {};
    assertThat(MetricsReporters.combine(null, null)).isNull();
    assertThat(MetricsReporters.combine(null, reporter)).isSameAs(reporter);
    assertThat(MetricsReporters.combine(reporter, null)).isSameAs(reporter);
  }