@Test public void stopShouldLogWhenEnclosedClientFailToClose() throws IOException { Logger.getRootLogger().addAppender(appender); doThrow(IOException.class).when(client).close(); new DatadogReporter(registry, client, "foo", Option.empty(), Option.empty(), MetricFilter.ALL, TimeUnit.SECONDS, TimeUnit.SECONDS).stop(); verify(appender).doAppend(logCaptor.capture()); assertEquals("Error disconnecting from Datadog.", logCaptor.getValue().getRenderedMessage()); assertEquals(Level.WARN, logCaptor.getValue().getLevel()); }
@Override public void stop() { try { super.stop(); } finally { try { client.close(); } catch (IOException e) { LOG.warn("Error disconnecting from Datadog.", e); } } }
DatadogReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { client.close(); } catch (IOException e) { LOG.warn("Error disconnecting from Datadog.", e); } } } }
DatadogReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { client.close(); } catch (IOException e) { LOG.warn("Error disconnecting from Datadog.", e); } } } protected  DatadogReporter(
      MetricRegistry registry,
      DatadogHttpClient client,
      String prefix,
      Option<String> host,
      Option<List<String>> tags,
      MetricFilter filter,
      TimeUnit rateUnit,
      TimeUnit durationUnit); }
DatadogReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { client.close(); } catch (IOException e) { LOG.warn("Error disconnecting from Datadog.", e); } } } protected  DatadogReporter(
      MetricRegistry registry,
      DatadogHttpClient client,
      String prefix,
      Option<String> host,
      Option<List<String>> tags,
      MetricFilter filter,
      TimeUnit rateUnit,
      TimeUnit durationUnit); @Override void report(
      SortedMap<String, Gauge> gauges,
      SortedMap<String, Counter> counters,
      SortedMap<String, Histogram> histograms,
      SortedMap<String, Meter> meters,
      SortedMap<String, Timer> timers); @Override void stop(); }
DatadogReporter extends ScheduledReporter { @Override public void stop() { try { super.stop(); } finally { try { client.close(); } catch (IOException e) { LOG.warn("Error disconnecting from Datadog.", e); } } } protected  DatadogReporter(
      MetricRegistry registry,
      DatadogHttpClient client,
      String prefix,
      Option<String> host,
      Option<List<String>> tags,
      MetricFilter filter,
      TimeUnit rateUnit,
      TimeUnit durationUnit); @Override void report(
      SortedMap<String, Gauge> gauges,
      SortedMap<String, Counter> counters,
      SortedMap<String, Histogram> histograms,
      SortedMap<String, Meter> meters,
      SortedMap<String, Timer> timers); @Override void stop();  }