ElasticsearchReporterProvider implements Provider<ElasticsearchReporter> { @Override public ElasticsearchReporter get() { final List<String> hosts = configuration.getHosts(); try { return ElasticsearchReporter.forRegistry(metricRegistry) .hosts(hosts.toArray(new String[hosts.size()])) .timeout(Ints.saturatedCast(configuration.getConnectTimeout().toMilliseconds())) .index(configuration.getIndex()) .bulkSize(configuration.getBulkSize()) .timestampFieldname(configuration.getTimestampFieldname()) .indexDateFormat(configuration.getIndexDateFormat()) .additionalFields(configuration.getAdditionalFields()) .prefixedWith(configuration.getPrefix()) .convertDurationsTo(configuration.getUnitDurations()) .convertRatesTo(configuration.getUnitRates()) .filter(new RegexMetricFilter(configuration.getIncludeMetrics())) .build(); } catch (IOException e) { throw new UncheckedIOException(e); } } @Inject  ElasticsearchReporterProvider(MetricsElasticsearchReporterConfiguration configuration,
                                         MetricRegistry metricRegistry); @Override ElasticsearchReporter get();  }
@Test public void get() throws Exception { final MetricsElasticsearchReporterConfiguration configuration = new MetricsElasticsearchReporterConfiguration(); final ElasticsearchReporterProvider provider = new ElasticsearchReporterProvider(configuration, new MetricRegistry()); final ElasticsearchReporter reporter = provider.get(); assertNotNull(reporter); }