diff options
author | Mayur Kale <mayurkale@google.com> | 2018-10-10 12:31:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-10 12:31:51 -0700 |
commit | 9c4df3dbe085a70850cc466849d33d90ffa846f4 (patch) | |
tree | f36c626bae1ec48ac2209be310d4e30d929db7b6 /impl_core/src | |
parent | e3b2074a090836985307123517fd2d361c4b503c (diff) | |
download | opencensus-java-9c4df3dbe085a70850cc466849d33d90ffa846f4.tar.gz |
Metrics/TimeSeries: Add createWithOnePoint method to accept only one … (#1486)
* Metrics/TimeSeries: Add createWithOnePoint method to accept only one point
* Fix reviews
* Minor Fix
Diffstat (limited to 'impl_core/src')
4 files changed, 17 insertions, 22 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java b/impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java index 30e5bf36..06cfbc1e 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java +++ b/impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java @@ -63,10 +63,9 @@ abstract class Gauge { @Override TimeSeries getTimeSeries(Clock clock) { - return TimeSeries.create( + return TimeSeries.createWithOnePoint( getLabelValues(), - Collections.singletonList( - Point.create(Value.doubleValue(function.applyAsDouble(obj)), clock.now())), + Point.create(Value.doubleValue(function.applyAsDouble(obj)), clock.now()), null); } } @@ -92,10 +91,9 @@ abstract class Gauge { @Override TimeSeries getTimeSeries(Clock clock) { - return TimeSeries.create( + return TimeSeries.createWithOnePoint( getLabelValues(), - Collections.singletonList( - Point.create(Value.longValue(function.applyAsLong(obj)), clock.now())), + Point.create(Value.longValue(function.applyAsLong(obj)), clock.now()), null); } } diff --git a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java index 0d25b292..928675e9 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java +++ b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java @@ -139,8 +139,7 @@ abstract class MutableViewData { tagValueAggregationMap.entrySet()) { List<LabelValue> labelValues = MetricUtils.tagValuesToLabelValues(entry.getKey()); Point point = entry.getValue().toPoint(now); - timeSeriesList.add( - TimeSeries.create(labelValues, Collections.singletonList(point), startTime)); + timeSeriesList.add(TimeSeries.createWithOnePoint(labelValues, point, startTime)); } return Metric.create(metricDescriptor, timeSeriesList); } diff --git a/impl_core/src/test/java/io/opencensus/implcore/metrics/GaugeTest.java b/impl_core/src/test/java/io/opencensus/implcore/metrics/GaugeTest.java index 161ad348..e5e4cbc5 100644 --- a/impl_core/src/test/java/io/opencensus/implcore/metrics/GaugeTest.java +++ b/impl_core/src/test/java/io/opencensus/implcore/metrics/GaugeTest.java @@ -89,10 +89,9 @@ public class GaugeTest { Metric.create( MetricDescriptor.create(NAME, DESCRIPTION, UNIT, Type.GAUGE_INT64, LABEL_KEYS), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( LABEL_VALUES, - Collections.singletonList( - Point.create(Value.longValue(OBJ.hashCode()), TEST_TIME)), + Point.create(Value.longValue(OBJ.hashCode()), TEST_TIME), null)))); } @@ -103,10 +102,9 @@ public class GaugeTest { Metric.create( MetricDescriptor.create(NAME, DESCRIPTION, UNIT, Type.GAUGE_DOUBLE, LABEL_KEYS), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( LABEL_VALUES, - Collections.singletonList( - Point.create(Value.doubleValue(OBJ.hashCode()), TEST_TIME)), + Point.create(Value.doubleValue(OBJ.hashCode()), TEST_TIME), null)))); } } diff --git a/impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java b/impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java index 3a5cb493..5210b266 100644 --- a/impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java +++ b/impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java @@ -159,9 +159,9 @@ public class MetricRegistryImplTest { Type.GAUGE_DOUBLE, Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)), - Collections.singletonList(Point.create(Value.doubleValue(5.0), TEST_TIME)), + Point.create(Value.doubleValue(5.0), TEST_TIME), null)))); } @@ -263,9 +263,9 @@ public class MetricRegistryImplTest { Type.GAUGE_INT64, Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)), - Collections.singletonList(Point.create(Value.longValue(7), TEST_TIME)), + Point.create(Value.longValue(7), TEST_TIME), null)))); } @@ -305,9 +305,9 @@ public class MetricRegistryImplTest { Type.GAUGE_INT64, Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)), - Collections.singletonList(Point.create(Value.longValue(7), TEST_TIME)), + Point.create(Value.longValue(7), TEST_TIME), null))), Metric.create( MetricDescriptor.create( @@ -317,9 +317,9 @@ public class MetricRegistryImplTest { Type.GAUGE_DOUBLE, Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))), Collections.singletonList( - TimeSeries.create( + TimeSeries.createWithOnePoint( Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)), - Collections.singletonList(Point.create(Value.doubleValue(5.0), TEST_TIME)), + Point.create(Value.doubleValue(5.0), TEST_TIME), null)))); } |