private void flush(GaugeWriter writer) { if (writer instanceof CompositeMetricWriter) { for (MetricWriter child : (CompositeMetricWriter) writer) { flush(child); } } try { if (ClassUtils.isPresent("java.io.Flushable", null)) { if (writer instanceof Flushable) { ((Flushable) writer).flush(); return; } } Method method = ReflectionUtils.findMethod(writer.getClass(), "flush"); if (method != null) { ReflectionUtils.invokeMethod(method, writer); } } catch (Exception ex) { logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": " + ex.getMessage()); } }
/** * 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; } }
private MetricCopyExporter getExporter(GaugeWriter writer, TriggerProperties trigger) { MetricCopyExporter exporter = new MetricCopyExporter(this.reader, writer); exporter.setIncludes(trigger.getIncludes()); exporter.setExcludes(trigger.getExcludes()); exporter.setSendLatest(trigger.isSendLatest()); return exporter; }
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 @ConfigurationProperties("metrics.export") @ExportMetricWriter public GaugeWriter openTsdbMetricWriter() { OpenTsdbGaugeWriter writer = new OpenTsdbGaugeWriter(); writer.setNamingStrategy(namingStrategy()); return writer; }
public void setWriters(Map<String, GaugeWriter> writers) { this.writers.putAll(writers); }
/** * 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, ""); }