public MetricExportAutoConfiguration(MetricExportProperties properties, ObjectProvider<MetricsEndpointMetricReader> endpointReaderProvider, @ExportMetricReader ObjectProvider<List<MetricReader>> readersProvider, @ExportMetricWriter ObjectProvider<Map<String, GaugeWriter>> writersProvider, ObjectProvider<Map<String, Exporter>> exportersProvider) { this.properties = properties; this.endpointReader = endpointReaderProvider.getIfAvailable(); this.readers = readersProvider.getIfAvailable(); this.writers = writersProvider.getIfAvailable(); this.exporters = exportersProvider.getIfAvailable(); }
@Test public void exportMetricsEndpoint() { this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricEndpointConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); MetricExporters exporters = this.context.getBean(MetricExporters.class); MetricCopyExporter exporter = (MetricCopyExporter) exporters.getExporters() .get("writer"); exporter.setIgnoreTimestamps(true); exporter.export(); MetricsEndpointMetricReader reader = this.context.getBean("endpointReader", MetricsEndpointMetricReader.class); Mockito.verify(reader, Mockito.atLeastOnce()).findAll(); }
/** * Enable a metrics reader. * @param metricsEndpoint {@link MetricsEndpoint} * @return {@link MetricsEndpointMetricReader} */ @Bean @ConditionalOnProperty(value = "statful.client.springboot.metrics.enabled", havingValue = "true") public MetricsEndpointMetricReader metricsEndpointMetricReader(final MetricsEndpoint metricsEndpoint) { return new MetricsEndpointMetricReader(metricsEndpoint); }
@Bean @ExportMetricReader public MetricsEndpointMetricReader endpointReader() { return Mockito.mock(MetricsEndpointMetricReader.class); }
public ApplicationMetricsExporter(MetricsEndpoint endpoint, MessageChannel source, ApplicationMetricsProperties properties) { this.source = source; this.properties = properties; this.metricsReader = new MetricsEndpointMetricReader(endpoint); }