/** * Reads the metrics from the {@link MetricProducerManager} and exports them to the {@code * metricExporter}. * * @param metricExporter the exporter called to export the metrics read. * @since 0.19 */ public void readAndExport(MetricExporter metricExporter) { Span span = tracer .spanBuilder(spanName) .setRecordEvents(true) .setSampler(probabilitySampler) .startSpan(); Scope scope = tracer.withSpan(span); try { ArrayList<Metric> metricsList = new ArrayList<>(); for (MetricProducer metricProducer : metricProducerManager.getAllMetricProducer()) { metricsList.addAll(metricProducer.getMetrics()); } metricExporter.export(metricsList); } catch (Throwable e) { logger.log(Level.WARNING, "Exception thrown by the metrics exporter.", e); span.setStatus( Status.UNKNOWN.withDescription("Exception when export metrics: " + exceptionMessage(e))); } finally { scope.close(); span.end(); } }
/** * Reads the metrics from the {@link MetricProducerManager} and exports them to the {@code * metricExporter}. * * @param metricExporter the exporter called to export the metrics read. * @since 0.19 */ public void readAndExport(MetricExporter metricExporter) { Span span = tracer .spanBuilder(spanName) .setRecordEvents(true) .setSampler(probabilitySampler) .startSpan(); Scope scope = tracer.withSpan(span); try { ArrayList<Metric> metricsList = new ArrayList<>(); for (MetricProducer metricProducer : metricProducerManager.getAllMetricProducer()) { metricsList.addAll(metricProducer.getMetrics()); } metricExporter.export(metricsList); } catch (Throwable e) { logger.log(Level.WARNING, "Exception thrown by the metrics exporter.", e); span.setStatus( Status.UNKNOWN.withDescription("Exception when export metrics: " + exceptionMessage(e))); } finally { scope.close(); span.end(); } }