/** * Create a new {@link MetricCopyExporter} instance. * @param reader the metric reader * @param writer the metric writer * @param prefix the name prefix */ public MetricCopyExporter(MetricReader reader, GaugeWriter writer, String prefix) { super(prefix); this.reader = reader; this.writer = writer; if (writer instanceof CounterWriter) { this.counter = (CounterWriter) writer; } else { this.counter = null; } }
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(); }
@Bean public MetricReaderPublicMetrics metricReaderPublicMetrics() { return new MetricReaderPublicMetrics( new CompositeMetricReader(this.metricReaders == null ? new MetricReader[0] : this.metricReaders .toArray(new MetricReader[this.metricReaders.size()]))); }
@Test public void createServices() throws Exception { this.context = new AnnotationConfigApplicationContext( MetricRepositoryAutoConfiguration.class); GaugeService gaugeService = this.context.getBean(BufferGaugeService.class); assertThat(gaugeService).isNotNull(); assertThat(this.context.getBean(BufferCounterService.class)).isNotNull(); assertThat(this.context.getBean(PrefixMetricReader.class)).isNotNull(); gaugeService.submit("foo", 2.7); MetricReader bean = this.context.getBean(MetricReader.class); assertThat(bean.findOne("gauge.foo").getValue()).isEqualTo(2.7); }
@Test public void exposesMetrics() { List<Metric<?>> metrics = new ArrayList<Metric<?>>(); metrics.add(mock(Metric.class)); metrics.add(mock(Metric.class)); MetricReader reader = mock(MetricReader.class); given(reader.findAll()).willReturn(metrics); MetricReaderPublicMetrics publicMetrics = new MetricReaderPublicMetrics(reader); assertThat(publicMetrics.metrics()).isEqualTo(metrics); }
@Test public void createServices() throws Exception { this.context = new AnnotationConfigApplicationContext( MetricRepositoryAutoConfiguration.class); GaugeService gaugeService = this.context.getBean(BufferGaugeService.class); assertNotNull(gaugeService); assertNotNull(this.context.getBean(BufferCounterService.class)); assertNotNull(this.context.getBean(PrefixMetricReader.class)); gaugeService.submit("foo", 2.7); assertEquals(2.7, this.context.getBean(MetricReader.class).findOne("gauge.foo").getValue()); }
@Test public void exposesMetrics() { List<Metric<?>> metrics = new ArrayList<Metric<?>>(); metrics.add(mock(Metric.class)); metrics.add(mock(Metric.class)); MetricReader reader = mock(MetricReader.class); given(reader.findAll()).willReturn(metrics); MetricReaderPublicMetrics publicMetrics = new MetricReaderPublicMetrics(reader); assertEquals(metrics, publicMetrics.metrics()); }
public MetricsListener(GaugeService gaugeService, RichGaugeReader richGaugeReader, MetricReader metricReader, List<Exporter> exporters) { this.gaugeService = gaugeService; this.richGaugeReader = richGaugeReader; this.metricReader = metricReader; this.exporters = exporters; }
private MetricReader globalMetricsForAggregation() { return new RedisMetricRepository(this.redisConnectionFactory, this.export.getRedis().getAggregatePrefix(), this.export.getRedis().getKey()); }
private MetricReader aggregatesMetricReader() { AggregateMetricReader repository = new AggregateMetricReader(globalMetricsForAggregation()); return repository; }
public AggregateMetricReader(MetricReader source) { this.source = source; }
PatternMatchingIterable(MetricReader reader) { this.reader = reader; }
public void setReader(MetricReader reader) { this.reader = reader; }
public PublicMetricsAutoConfiguration( @ExportMetricReader ObjectProvider<List<MetricReader>> metricReadersProvider) { this.metricReaders = metricReadersProvider.getIfAvailable(); }
public MetricReaderPublicMetrics(MetricReader metricReader) { Assert.notNull(metricReader, "MetricReader must not be null"); this.metricReader = metricReader; }
private MetricReader globalMetricsForAggregation() { return new RedisMetricRepository(this.connectionFactory, this.export.getRedis().getAggregatePrefix(), this.export.getRedis().getKey()); }
private MetricReader aggregatesMetricReader() { AggregateMetricReader repository = new AggregateMetricReader( globalMetricsForAggregation()); repository.setKeyPattern(this.export.getAggregate().getKeyPattern()); return repository; }
/** * Exports a metric reader * @return a metric reader */ @Bean @ExportMetricReader public MetricReader metricReader() { return new MetricRegistryMetricReader(sharedRegistry); }
@Bean public MetricReaderPublicMetrics metricReaderPublicMetrics() { return new MetricReaderPublicMetrics(new CompositeMetricReader( this.metricReaders.toArray(new MetricReader[0]))); }
/** * Create a new {@link MetricCopyExporter} instance. * @param reader the metric reader * @param writer the metric writer */ public MetricCopyExporter(MetricReader reader, GaugeWriter writer) { this(reader, writer, ""); }
/** * Create a new {@link MetricCopyExporter} instance. * @param reader the metric reader * @param writer the metric writer */ public MetricCopyExporter(MetricReader reader, MetricWriter writer) { this(reader, writer, ""); }