private void onCounterData(MetricData metricData) { Observable<Metric<Long>> metrics = Observable.from(metricData.getData()) .map( singleMetric -> { MetricId<Long> id = new MetricId<>(metricData.getTenantId(), COUNTER, singleMetric.getSource()); long value = (long) singleMetric.getValue(); DataPoint<Long> dataPoint = new DataPoint<>(singleMetric.getTimestamp(), value); return new Metric<>(id, Collections.singletonList(dataPoint)); }); metricsService.addDataPoints(COUNTER, metrics).subscribe(new NewDataSubscriber()); }
private void onGaugeData(MetricData metricData) { Observable<Metric<Double>> metrics = Observable.from(metricData.getData()) .map( singleMetric -> { MetricId<Double> id = new MetricId<>(metricData.getTenantId(), GAUGE, singleMetric.getSource()); DataPoint<Double> dataPoint = new DataPoint<>(singleMetric.getTimestamp(), singleMetric.getValue()); return new Metric<>(id, Collections.singletonList(dataPoint)); }); metricsService.addDataPoints(GAUGE, metrics).subscribe(new NewDataSubscriber()); }