DatadogReporterProvider implements Provider<DatadogReporter> { @Override public DatadogReporter get() { final DatadogReporter.Builder builder = DatadogReporter.forRegistry(metricRegistry) .withTransport(transport) .withPrefix(configuration.getPrefix()) .convertRatesTo(configuration.getUnitRates()) .convertDurationsTo(configuration.getUnitDurations()) .filter(new RegexMetricFilter(configuration.getIncludeMetrics())); if (configuration.isEC2Instance()) { try { builder.withEC2Host(); } catch (IOException e) { throw new UncheckedIOException(e); } } else { builder.withHost(configuration.getHostname()); } return builder.build(); } @Inject  DatadogReporterProvider(MetricsDatadogReporterConfiguration configuration,
                                   Transport transport,
                                   MetricRegistry metricRegistry); @Override DatadogReporter get();  }
@Test public void get() throws Exception { final MetricsDatadogReporterConfiguration configuration = new MetricsDatadogReporterConfiguration(); final Transport graphiteSender = new UdpTransport.Builder().build(); final MetricRegistry metricRegistry = new MetricRegistry(); final DatadogReporterProvider provider = new DatadogReporterProvider(configuration, graphiteSender, metricRegistry); final DatadogReporter reporter = provider.get(); assertNotNull(reporter); }