aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Song <songy23@users.noreply.github.com>2018-08-21 13:14:31 -0700
committerGitHub <noreply@github.com>2018-08-21 13:14:31 -0700
commit8d75c101ab0ae0efd5faea9906ce399f00fb4394 (patch)
treefe63865bbb7fbd7b6e86dd88dfe4825331d6b5b6
parent07ede4e46f2256917b4d4fb0968c09817b33b10a (diff)
downloadopencensus-java-8d75c101ab0ae0efd5faea9906ce399f00fb4394.tar.gz
Metrics: Combine TimeSeriesCumulative and TimeSeriesGauge. (#1380)
-rw-r--r--api/src/main/java/io/opencensus/metrics/Metric.java61
-rw-r--r--api/src/main/java/io/opencensus/metrics/TimeSeries.java50
-rw-r--r--api/src/main/java/io/opencensus/metrics/TimeSeriesCumulative.java70
-rw-r--r--api/src/main/java/io/opencensus/metrics/TimeSeriesGauge.java57
-rw-r--r--api/src/main/java/io/opencensus/metrics/TimeSeriesList.java134
-rw-r--r--api/src/test/java/io/opencensus/metrics/MetricTest.java59
-rw-r--r--api/src/test/java/io/opencensus/metrics/TimeSeriesGaugeTest.java104
-rw-r--r--api/src/test/java/io/opencensus/metrics/TimeSeriesListTest.java135
-rw-r--r--api/src/test/java/io/opencensus/metrics/TimeSeriesTest.java (renamed from api/src/test/java/io/opencensus/metrics/TimeSeriesCumulativeTest.java)37
-rw-r--r--impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java24
-rw-r--r--impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java41
-rw-r--r--impl_core/src/test/java/io/opencensus/implcore/metrics/GaugeTest.java27
-rw-r--r--impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java47
13 files changed, 185 insertions, 661 deletions
diff --git a/api/src/main/java/io/opencensus/metrics/Metric.java b/api/src/main/java/io/opencensus/metrics/Metric.java
index e8be0b90..9cbd418b 100644
--- a/api/src/main/java/io/opencensus/metrics/Metric.java
+++ b/api/src/main/java/io/opencensus/metrics/Metric.java
@@ -19,8 +19,10 @@ package io.opencensus.metrics;
import com.google.auto.value.AutoValue;
import io.opencensus.common.ExperimentalApi;
import io.opencensus.internal.Utils;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesCumulativeList;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesGaugeList;
+import io.opencensus.metrics.Value.ValueDistribution;
+import io.opencensus.metrics.Value.ValueDouble;
+import io.opencensus.metrics.Value.ValueLong;
+import java.util.List;
import javax.annotation.concurrent.Immutable;
/**
@@ -39,11 +41,11 @@ public abstract class Metric {
* Creates a {@link Metric}.
*
* @param metricDescriptor the {@link MetricDescriptor}.
- * @param timeSeriesList the {@link TimeSeriesList} for this metric.
+ * @param timeSeriesList the {@link TimeSeries} list for this metric.
* @return a {@code Metric}.
* @since 0.16
*/
- public static Metric create(MetricDescriptor metricDescriptor, TimeSeriesList timeSeriesList) {
+ public static Metric create(MetricDescriptor metricDescriptor, List<TimeSeries> timeSeriesList) {
checkTypeMatch(metricDescriptor.getType(), timeSeriesList);
return new AutoValue_Metric(metricDescriptor, timeSeriesList);
}
@@ -57,32 +59,43 @@ public abstract class Metric {
public abstract MetricDescriptor getMetricDescriptor();
/**
- * Returns the {@link TimeSeriesList} for this metric.
+ * Returns the {@link TimeSeries} list for this metric.
*
- * <p>The type of the {@link TimeSeriesList} must match {@link MetricDescriptor.Type}.
+ * <p>The type of the {@link TimeSeries#getPoints()} must match {@link MetricDescriptor.Type}.
*
* @return the {@code TimeSeriesList} for this metric.
* @since 0.16
*/
- public abstract TimeSeriesList getTimeSeriesList();
+ public abstract List<TimeSeries> getTimeSeriesList();
- private static void checkTypeMatch(MetricDescriptor.Type type, TimeSeriesList timeSeriesList) {
- switch (type) {
- case GAUGE_INT64:
- case GAUGE_DOUBLE:
- Utils.checkArgument(
- timeSeriesList instanceof TimeSeriesGaugeList,
- String.format(
- "Type mismatch: %s, %s.", type, timeSeriesList.getClass().getSimpleName()));
- break;
- case CUMULATIVE_DISTRIBUTION:
- case CUMULATIVE_DOUBLE:
- case CUMULATIVE_INT64:
- Utils.checkArgument(
- timeSeriesList instanceof TimeSeriesCumulativeList,
- String.format(
- "Type mismatch: %s, %s.", type, timeSeriesList.getClass().getSimpleName()));
- break;
+ private static void checkTypeMatch(MetricDescriptor.Type type, List<TimeSeries> timeSeriesList) {
+ for (TimeSeries timeSeries : timeSeriesList) {
+ for (Point point : timeSeries.getPoints()) {
+ Value value = point.getValue();
+ String valueClassName = "";
+ if (value.getClass().getSuperclass() != null) { // work around nullness check
+ // AutoValue classes should always have a super class.
+ valueClassName = value.getClass().getSuperclass().getSimpleName();
+ }
+ switch (type) {
+ case GAUGE_INT64:
+ case CUMULATIVE_INT64:
+ Utils.checkArgument(
+ value instanceof ValueLong,
+ String.format("Type mismatch: %s, %s.", type, valueClassName));
+ break;
+ case CUMULATIVE_DOUBLE:
+ case GAUGE_DOUBLE:
+ Utils.checkArgument(
+ value instanceof ValueDouble,
+ String.format("Type mismatch: %s, %s.", type, valueClassName));
+ break;
+ case CUMULATIVE_DISTRIBUTION:
+ Utils.checkArgument(
+ value instanceof ValueDistribution,
+ String.format("Type mismatch: %s, %s.", type, valueClassName));
+ }
+ }
}
}
}
diff --git a/api/src/main/java/io/opencensus/metrics/TimeSeries.java b/api/src/main/java/io/opencensus/metrics/TimeSeries.java
index bbbfe0e4..c62b6b72 100644
--- a/api/src/main/java/io/opencensus/metrics/TimeSeries.java
+++ b/api/src/main/java/io/opencensus/metrics/TimeSeries.java
@@ -16,16 +16,52 @@
package io.opencensus.metrics;
+import com.google.auto.value.AutoValue;
+import io.opencensus.common.ExperimentalApi;
+import io.opencensus.common.Timestamp;
+import io.opencensus.internal.Utils;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
-/** A collection of data points that describes the time-varying values of a {@code Metric}. */
+/**
+ * A collection of data points that describes the time-varying values of a {@code Metric}.
+ *
+ * @since 0.16
+ */
+@ExperimentalApi
@Immutable
-abstract class TimeSeries {
+@AutoValue
+public abstract class TimeSeries {
TimeSeries() {}
/**
+ * Creates a {@link TimeSeries}.
+ *
+ * @param labelValues the {@code LabelValue}s that uniquely identify this {@code TimeSeries}.
+ * @param points the data {@code Point}s of this {@code TimeSeries}.
+ * @param startTimestamp the start {@code Timestamp} of this {@code TimeSeries}. Must be non-null
+ * for cumulative {@code Point}s.
+ * @return a {@code TimeSeries}.
+ * @since 0.16
+ */
+ public static TimeSeries create(
+ List<LabelValue> labelValues, List<Point> points, @Nullable Timestamp startTimestamp) {
+ // Fail fast on null lists to prevent NullPointerException when copying the lists.
+ Utils.checkNotNull(labelValues, "labelValues");
+ Utils.checkNotNull(points, "points");
+ Utils.checkListElementNotNull(labelValues, "labelValue");
+ Utils.checkListElementNotNull(points, "point");
+ return new AutoValue_TimeSeries(
+ Collections.unmodifiableList(new ArrayList<LabelValue>(labelValues)),
+ Collections.unmodifiableList(new ArrayList<Point>(points)),
+ startTimestamp);
+ }
+
+ /**
* Returns the set of {@link LabelValue}s that uniquely identify this {@link TimeSeries}.
*
* <p>Apply to all {@link Point}s.
@@ -45,4 +81,14 @@ abstract class TimeSeries {
* @since 0.16
*/
public abstract List<Point> getPoints();
+
+ /**
+ * Returns the start {@link Timestamp} of this {@link TimeSeries} if the {@link Point}s are
+ * cumulative, or {@code null} if the {@link Point}s are gauge.
+ *
+ * @return the start {@code Timestamp} or {@code null}.
+ * @since 0.16
+ */
+ @Nullable
+ public abstract Timestamp getStartTimestamp();
}
diff --git a/api/src/main/java/io/opencensus/metrics/TimeSeriesCumulative.java b/api/src/main/java/io/opencensus/metrics/TimeSeriesCumulative.java
deleted file mode 100644
index 5f48b770..00000000
--- a/api/src/main/java/io/opencensus/metrics/TimeSeriesCumulative.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2018, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.metrics;
-
-import com.google.auto.value.AutoValue;
-import io.opencensus.common.ExperimentalApi;
-import io.opencensus.common.Timestamp;
-import io.opencensus.internal.Utils;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.concurrent.Immutable;
-
-/**
- * A collection of data points that describes the time-varying values of a cumulative {@code
- * Metric}.
- *
- * @since 0.16
- */
-@ExperimentalApi
-@Immutable
-@AutoValue
-public abstract class TimeSeriesCumulative extends TimeSeries {
-
- TimeSeriesCumulative() {}
-
- /**
- * Creates a {@link TimeSeriesCumulative}.
- *
- * @param labelValues the {@code LabelValue}s that uniquely identify this {@code TimeSeries}.
- * @param points the data {@code Point}s of this {@code TimeSeries}.
- * @param startTimestamp the start {@code Timestamp} of this {@code TimeSeriesCumulative}.
- * @return a {@code TimeSeriesCumulative}.
- * @since 0.16
- */
- public static TimeSeriesCumulative create(
- List<LabelValue> labelValues, List<Point> points, Timestamp startTimestamp) {
- // Fail fast on null lists to prevent NullPointerException when copying the lists.
- Utils.checkNotNull(labelValues, "labelValues");
- Utils.checkNotNull(points, "points");
- Utils.checkListElementNotNull(labelValues, "labelValue");
- Utils.checkListElementNotNull(points, "point");
- return new AutoValue_TimeSeriesCumulative(
- Collections.unmodifiableList(new ArrayList<LabelValue>(labelValues)),
- Collections.unmodifiableList(new ArrayList<Point>(points)),
- startTimestamp);
- }
-
- /**
- * Returns the start {@link Timestamp} of this {@link TimeSeriesCumulative}.
- *
- * @return the start {@code Timestamp}.
- * @since 0.16
- */
- public abstract Timestamp getStartTimestamp();
-}
diff --git a/api/src/main/java/io/opencensus/metrics/TimeSeriesGauge.java b/api/src/main/java/io/opencensus/metrics/TimeSeriesGauge.java
deleted file mode 100644
index 717505a4..00000000
--- a/api/src/main/java/io/opencensus/metrics/TimeSeriesGauge.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2018, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.metrics;
-
-import com.google.auto.value.AutoValue;
-import io.opencensus.common.ExperimentalApi;
-import io.opencensus.internal.Utils;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.concurrent.Immutable;
-
-/**
- * A collection of data points that describes the time-varying values of a gauge {@code Metric}.
- *
- * @since 0.16
- */
-@ExperimentalApi
-@Immutable
-@AutoValue
-public abstract class TimeSeriesGauge extends TimeSeries {
-
- TimeSeriesGauge() {}
-
- /**
- * Creates a {@link TimeSeriesGauge}.
- *
- * @param labelValues the {@code LabelValue}s that uniquely identify this {@code TimeSeries}.
- * @param points the data {@code Point}s of this {@code TimeSeries}.
- * @return a {@code TimeSeriesGauge}.
- * @since 0.16
- */
- public static TimeSeriesGauge create(List<LabelValue> labelValues, List<Point> points) {
- // Fail fast on null lists to prevent NullPointerException when copying the lists.
- Utils.checkNotNull(labelValues, "labelValues");
- Utils.checkNotNull(points, "points");
- Utils.checkListElementNotNull(labelValues, "labelValue");
- Utils.checkListElementNotNull(points, "point");
- return new AutoValue_TimeSeriesGauge(
- Collections.unmodifiableList(new ArrayList<LabelValue>(labelValues)),
- Collections.unmodifiableList(new ArrayList<Point>(points)));
- }
-}
diff --git a/api/src/main/java/io/opencensus/metrics/TimeSeriesList.java b/api/src/main/java/io/opencensus/metrics/TimeSeriesList.java
deleted file mode 100644
index 6138eac2..00000000
--- a/api/src/main/java/io/opencensus/metrics/TimeSeriesList.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2018, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.metrics;
-
-import com.google.auto.value.AutoValue;
-import io.opencensus.common.ExperimentalApi;
-import io.opencensus.common.Function;
-import io.opencensus.internal.Utils;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.concurrent.Immutable;
-
-/**
- * Class that holds a list of either {@link TimeSeriesGauge} or {@link TimeSeriesCumulative}.
- *
- * @since 0.16
- */
-@ExperimentalApi
-@Immutable
-public abstract class TimeSeriesList {
-
- TimeSeriesList() {}
-
- /**
- * Applies the given match function to the underlying data type.
- *
- * @since 0.16
- */
- public abstract <T> T match(
- Function<? super TimeSeriesGaugeList, T> gaugeListFunction,
- Function<? super TimeSeriesCumulativeList, T> cumulativeListFunction,
- Function<? super TimeSeriesList, T> defaultFunction);
-
- /**
- * Class that holds a list of {@link TimeSeriesGauge}.
- *
- * @since 0.16
- */
- @ExperimentalApi
- @Immutable
- @AutoValue
- public abstract static class TimeSeriesGaugeList extends TimeSeriesList {
-
- TimeSeriesGaugeList() {}
-
- @Override
- public final <T> T match(
- Function<? super TimeSeriesGaugeList, T> gaugeListFunction,
- Function<? super TimeSeriesCumulativeList, T> cumulativeListFunction,
- Function<? super TimeSeriesList, T> defaultFunction) {
- return gaugeListFunction.apply(this);
- }
-
- /**
- * Creates a {@link TimeSeriesGaugeList}.
- *
- * @param list a list of {@link TimeSeriesGauge}.
- * @return a {code TimeSeriesGaugeList}.
- * @since 0.16
- */
- public static TimeSeriesGaugeList create(List<TimeSeriesGauge> list) {
- Utils.checkNotNull(list, "list");
- Utils.checkListElementNotNull(list, "timeSeriesGauge");
- return new AutoValue_TimeSeriesList_TimeSeriesGaugeList(
- Collections.unmodifiableList(new ArrayList<TimeSeriesGauge>(list)));
- }
-
- /**
- * Returns the list of {@link TimeSeriesGauge}.
- *
- * @return the list of {@code TimeSeriesGauge}.
- * @since 0.16
- */
- public abstract List<TimeSeriesGauge> getList();
- }
-
- /**
- * Class that holds a list of {@link TimeSeriesCumulative}.
- *
- * @since 0.16
- */
- @ExperimentalApi
- @Immutable
- @AutoValue
- public abstract static class TimeSeriesCumulativeList extends TimeSeriesList {
-
- TimeSeriesCumulativeList() {}
-
- @Override
- public final <T> T match(
- Function<? super TimeSeriesGaugeList, T> gaugeListFunction,
- Function<? super TimeSeriesCumulativeList, T> cumulativeListFunction,
- Function<? super TimeSeriesList, T> defaultFunction) {
- return cumulativeListFunction.apply(this);
- }
-
- /**
- * Creates a {@link TimeSeriesCumulativeList}.
- *
- * @param list a list of {@link TimeSeriesCumulative}.
- * @return a {code TimeSeriesCumulativeList}.
- * @since 0.16
- */
- public static TimeSeriesCumulativeList create(List<TimeSeriesCumulative> list) {
- Utils.checkNotNull(list, "list");
- Utils.checkListElementNotNull(list, "timeSeriesCumulative");
- return new AutoValue_TimeSeriesList_TimeSeriesCumulativeList(
- Collections.unmodifiableList(new ArrayList<TimeSeriesCumulative>(list)));
- }
-
- /**
- * Returns the list of {@link TimeSeriesCumulative}.
- *
- * @return the list of {@code TimeSeriesCumulative}.
- * @since 0.16
- */
- public abstract List<TimeSeriesCumulative> getList();
- }
-}
diff --git a/api/src/test/java/io/opencensus/metrics/MetricTest.java b/api/src/test/java/io/opencensus/metrics/MetricTest.java
index 59838ef4..37deed4b 100644
--- a/api/src/test/java/io/opencensus/metrics/MetricTest.java
+++ b/api/src/test/java/io/opencensus/metrics/MetricTest.java
@@ -21,10 +21,9 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.testing.EqualsTester;
import io.opencensus.common.Timestamp;
import io.opencensus.metrics.MetricDescriptor.Type;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesCumulativeList;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesGaugeList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -61,47 +60,41 @@ public class MetricTest {
private static final Point POINT_1 = Point.create(VALUE_DOUBLE_1, TIMESTAMP_2);
private static final Point POINT_2 = Point.create(VALUE_DOUBLE_2, TIMESTAMP_3);
private static final Point POINT_3 = Point.create(VALUE_LONG, TIMESTAMP_3);
- private static final TimeSeriesGauge GAUGE_TIME_SERIES_1 =
- TimeSeriesGauge.create(Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1));
- private static final TimeSeriesGauge GAUGE_TIME_SERIES_2 =
- TimeSeriesGauge.create(Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_2));
- private static final TimeSeriesCumulative CUMULATIVE_TIME_SERIES =
- TimeSeriesCumulative.create(
- Arrays.asList(LABEL_VALUE_EMPTY), Arrays.asList(POINT_3), TIMESTAMP_1);
- private static final TimeSeriesGaugeList TIME_SERIES_GAUGE_LIST =
- TimeSeriesGaugeList.create(Arrays.asList(GAUGE_TIME_SERIES_1, GAUGE_TIME_SERIES_2));
- private static final TimeSeriesCumulativeList TIME_SERIES_CUMULATIVE_LIST =
- TimeSeriesCumulativeList.create(Arrays.asList(CUMULATIVE_TIME_SERIES));
+ private static final TimeSeries GAUGE_TIME_SERIES_1 =
+ TimeSeries.create(Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), null);
+ private static final TimeSeries GAUGE_TIME_SERIES_2 =
+ TimeSeries.create(Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_2), null);
+ private static final TimeSeries CUMULATIVE_TIME_SERIES =
+ TimeSeries.create(Arrays.asList(LABEL_VALUE_EMPTY), Arrays.asList(POINT_3), TIMESTAMP_1);
@Test
public void testGet() {
- Metric metric = Metric.create(METRIC_DESCRIPTOR_1, TIME_SERIES_GAUGE_LIST);
+ Metric metric =
+ Metric.create(METRIC_DESCRIPTOR_1, Arrays.asList(GAUGE_TIME_SERIES_1, GAUGE_TIME_SERIES_2));
assertThat(metric.getMetricDescriptor()).isEqualTo(METRIC_DESCRIPTOR_1);
- assertThat(metric.getTimeSeriesList()).isEqualTo(TIME_SERIES_GAUGE_LIST);
+ assertThat(metric.getTimeSeriesList())
+ .containsExactly(GAUGE_TIME_SERIES_1, GAUGE_TIME_SERIES_2)
+ .inOrder();
}
@Test
- public void typeMismatch_GaugeDouble_TimeSeriesCumulative() {
+ public void typeMismatch_GaugeDouble_Long() {
typeMismatch(
METRIC_DESCRIPTOR_1,
- TIME_SERIES_CUMULATIVE_LIST,
- String.format(
- "Type mismatch: %s, %s.",
- Type.GAUGE_DOUBLE, TIME_SERIES_CUMULATIVE_LIST.getClass().getSimpleName()));
+ Arrays.asList(CUMULATIVE_TIME_SERIES),
+ String.format("Type mismatch: %s, %s.", Type.GAUGE_DOUBLE, "ValueLong"));
}
@Test
- public void typeMismatch_CumulativeInt64_TimeSeriesGauge() {
+ public void typeMismatch_CumulativeInt64_Double() {
typeMismatch(
METRIC_DESCRIPTOR_2,
- TIME_SERIES_GAUGE_LIST,
- String.format(
- "Type mismatch: %s, %s.",
- Type.CUMULATIVE_INT64, TIME_SERIES_GAUGE_LIST.getClass().getSimpleName()));
+ Arrays.asList(GAUGE_TIME_SERIES_1),
+ String.format("Type mismatch: %s, %s.", Type.CUMULATIVE_INT64, "ValueDouble"));
}
private void typeMismatch(
- MetricDescriptor metricDescriptor, TimeSeriesList timeSeriesList, String errorMessage) {
+ MetricDescriptor metricDescriptor, List<TimeSeries> timeSeriesList, String errorMessage) {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(errorMessage);
Metric.create(metricDescriptor, timeSeriesList);
@@ -111,17 +104,13 @@ public class MetricTest {
public void testEquals() {
new EqualsTester()
.addEqualityGroup(
- Metric.create(METRIC_DESCRIPTOR_1, TIME_SERIES_GAUGE_LIST),
- Metric.create(METRIC_DESCRIPTOR_1, TIME_SERIES_GAUGE_LIST))
- .addEqualityGroup(
Metric.create(
- METRIC_DESCRIPTOR_1,
- TimeSeriesGaugeList.create(Collections.<TimeSeriesGauge>emptyList())))
- .addEqualityGroup(Metric.create(METRIC_DESCRIPTOR_2, TIME_SERIES_CUMULATIVE_LIST))
- .addEqualityGroup(
+ METRIC_DESCRIPTOR_1, Arrays.asList(GAUGE_TIME_SERIES_1, GAUGE_TIME_SERIES_2)),
Metric.create(
- METRIC_DESCRIPTOR_2,
- TimeSeriesCumulativeList.create(Collections.<TimeSeriesCumulative>emptyList())))
+ METRIC_DESCRIPTOR_1, Arrays.asList(GAUGE_TIME_SERIES_1, GAUGE_TIME_SERIES_2)))
+ .addEqualityGroup(Metric.create(METRIC_DESCRIPTOR_1, Collections.<TimeSeries>emptyList()))
+ .addEqualityGroup(Metric.create(METRIC_DESCRIPTOR_2, Arrays.asList(CUMULATIVE_TIME_SERIES)))
+ .addEqualityGroup(Metric.create(METRIC_DESCRIPTOR_2, Collections.<TimeSeries>emptyList()))
.testEquals();
}
}
diff --git a/api/src/test/java/io/opencensus/metrics/TimeSeriesGaugeTest.java b/api/src/test/java/io/opencensus/metrics/TimeSeriesGaugeTest.java
deleted file mode 100644
index 83f7c267..00000000
--- a/api/src/test/java/io/opencensus/metrics/TimeSeriesGaugeTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2018, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.metrics;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.common.testing.EqualsTester;
-import io.opencensus.common.Timestamp;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.hamcrest.CoreMatchers;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Unit tests for {@link TimeSeriesGauge}. */
-@RunWith(JUnit4.class)
-public class TimeSeriesGaugeTest {
-
- @Rule public ExpectedException thrown = ExpectedException.none();
-
- private static final LabelValue LABEL_VALUE_1 = LabelValue.create("value1");
- private static final LabelValue LABEL_VALUE_2 = LabelValue.create("value2");
- private static final Value VALUE_LONG = Value.longValue(12345678);
- private static final Value VALUE_DOUBLE = Value.doubleValue(-345.77);
- private static final Timestamp TIMESTAMP_1 = Timestamp.fromMillis(1000);
- private static final Timestamp TIMESTAMP_2 = Timestamp.fromMillis(2000);
- private static final Point POINT_1 = Point.create(VALUE_DOUBLE, TIMESTAMP_1);
- private static final Point POINT_2 = Point.create(VALUE_LONG, TIMESTAMP_2);
-
- @Test
- public void testGet_TimeSeriesGauge() {
- TimeSeriesGauge gaugeTimeSeries =
- TimeSeriesGauge.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1, POINT_2));
- assertThat(gaugeTimeSeries.getLabelValues())
- .containsExactly(LABEL_VALUE_1, LABEL_VALUE_2)
- .inOrder();
- assertThat(gaugeTimeSeries.getPoints()).containsExactly(POINT_1, POINT_2).inOrder();
- }
-
- @Test
- public void create_WithNullLabelValueList() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("labelValues"));
- TimeSeriesGauge.create(null, Collections.<Point>emptyList());
- }
-
- @Test
- public void create_WithNullLabelValue() {
- List<LabelValue> labelValues = Arrays.asList(LABEL_VALUE_1, null);
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("labelValue"));
- TimeSeriesGauge.create(labelValues, Collections.<Point>emptyList());
- }
-
- @Test
- public void create_WithNullPointList() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("points"));
- TimeSeriesGauge.create(Collections.<LabelValue>emptyList(), null);
- }
-
- @Test
- public void create_WithNullPoint() {
- List<Point> points = Arrays.asList(POINT_1, null);
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("point"));
- TimeSeriesGauge.create(Collections.<LabelValue>emptyList(), points);
- }
-
- @Test
- public void testEquals() {
- new EqualsTester()
- .addEqualityGroup(
- TimeSeriesGauge.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1, POINT_2)),
- TimeSeriesGauge.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1, POINT_2)))
- .addEqualityGroup(
- TimeSeriesGauge.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1)))
- .addEqualityGroup(
- TimeSeriesGauge.create(Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_1)))
- .testEquals();
- }
-}
diff --git a/api/src/test/java/io/opencensus/metrics/TimeSeriesListTest.java b/api/src/test/java/io/opencensus/metrics/TimeSeriesListTest.java
deleted file mode 100644
index 46ace50f..00000000
--- a/api/src/test/java/io/opencensus/metrics/TimeSeriesListTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2018, OpenCensus Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.opencensus.metrics;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.common.testing.EqualsTester;
-import io.opencensus.common.Functions;
-import io.opencensus.common.Timestamp;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesCumulativeList;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesGaugeList;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.hamcrest.CoreMatchers;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Unit tests for {@link TimeSeries}. */
-@RunWith(JUnit4.class)
-public class TimeSeriesListTest {
-
- @Rule public ExpectedException thrown = ExpectedException.none();
-
- private static final LabelValue LABEL_VALUE_1 = LabelValue.create("value1");
- private static final LabelValue LABEL_VALUE_2 = LabelValue.create("value2");
- private static final LabelValue LABEL_VALUE_EMPTY = LabelValue.create("");
- private static final Value VALUE_LONG = Value.longValue(12345678);
- private static final Value VALUE_DOUBLE = Value.doubleValue(-345.77);
- private static final Timestamp TIMESTAMP_1 = Timestamp.fromMillis(1000);
- private static final Timestamp TIMESTAMP_2 = Timestamp.fromMillis(2000);
- private static final Timestamp TIMESTAMP_3 = Timestamp.fromMillis(3000);
- private static final Point POINT_1 = Point.create(VALUE_DOUBLE, TIMESTAMP_2);
- private static final Point POINT_2 = Point.create(VALUE_LONG, TIMESTAMP_3);
- private static final TimeSeriesGauge TIME_SERIES_GAUGE =
- TimeSeriesGauge.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1, POINT_2));
- private static final TimeSeriesCumulative TIME_SERIES_CUMULATIVE =
- TimeSeriesCumulative.create(
- Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_EMPTY), Arrays.asList(POINT_1), TIMESTAMP_1);
-
- @Test
- public void testGet_TimeSeriesGaugeList() {
- TimeSeriesGaugeList gaugeTimeSeriesList =
- TimeSeriesGaugeList.create(Collections.singletonList(TIME_SERIES_GAUGE));
- assertThat(gaugeTimeSeriesList.getList()).containsExactly(TIME_SERIES_GAUGE);
- }
-
- @Test
- public void testGet_TimeSeriesCumulativeList() {
- TimeSeriesCumulativeList cumulativeTimeSeriesList =
- TimeSeriesCumulativeList.create(Collections.singletonList(TIME_SERIES_CUMULATIVE));
- assertThat(cumulativeTimeSeriesList.getList()).containsExactly(TIME_SERIES_CUMULATIVE);
- }
-
- @Test
- public void createGaugeList_WithNullList() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("list"));
- TimeSeriesGaugeList.create(null);
- }
-
- @Test
- public void createGaugeList_WithNullTimeSeries() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("timeSeriesGauge"));
- TimeSeriesGaugeList.create(Arrays.asList(TIME_SERIES_GAUGE, null));
- }
-
- @Test
- public void createCumulativeList_WithNullList() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("list"));
- TimeSeriesCumulativeList.create(null);
- }
-
- @Test
- public void createCumulativeList_WithNullTimeSeries() {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage(CoreMatchers.equalTo("timeSeriesCumulative"));
- TimeSeriesCumulativeList.create(Arrays.asList(TIME_SERIES_CUMULATIVE, null));
- }
-
- @Test
- public void testEquals() {
- new EqualsTester()
- .addEqualityGroup(
- TimeSeriesGaugeList.create(Collections.singletonList(TIME_SERIES_GAUGE)),
- TimeSeriesGaugeList.create(Collections.singletonList(TIME_SERIES_GAUGE)))
- .addEqualityGroup(
- TimeSeriesCumulativeList.create(Collections.singletonList(TIME_SERIES_CUMULATIVE)),
- TimeSeriesCumulativeList.create(Collections.singletonList(TIME_SERIES_CUMULATIVE)))
- .addEqualityGroup(TimeSeriesGaugeList.create(Collections.<TimeSeriesGauge>emptyList()))
- .addEqualityGroup(
- TimeSeriesCumulativeList.create(Collections.<TimeSeriesCumulative>emptyList()))
- .testEquals();
- }
-
- @Test
- public void testMatch() {
- TimeSeriesList gaugeTimeSeriesList =
- TimeSeriesGaugeList.create(Collections.singletonList(TIME_SERIES_GAUGE));
- TimeSeriesList cumulativeTimeSeriesList =
- TimeSeriesCumulativeList.create(Collections.singletonList(TIME_SERIES_CUMULATIVE));
-
- final List<String> actual = new ArrayList<String>();
- for (TimeSeriesList timeSeriesList :
- Arrays.asList(cumulativeTimeSeriesList, gaugeTimeSeriesList)) {
- actual.add(
- timeSeriesList.match(
- Functions.returnConstant("TimeSeriesGaugeList"),
- Functions.returnConstant("TimeSeriesCumulativeList"),
- Functions.<String>throwAssertionError()));
- }
- assertThat(actual).containsExactly("TimeSeriesCumulativeList", "TimeSeriesGaugeList").inOrder();
- }
-}
diff --git a/api/src/test/java/io/opencensus/metrics/TimeSeriesCumulativeTest.java b/api/src/test/java/io/opencensus/metrics/TimeSeriesTest.java
index 3532a5a5..07dff97d 100644
--- a/api/src/test/java/io/opencensus/metrics/TimeSeriesCumulativeTest.java
+++ b/api/src/test/java/io/opencensus/metrics/TimeSeriesTest.java
@@ -30,9 +30,9 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/** Unit tests for {@link TimeSeriesCumulative}. */
+/** Unit tests for {@link TimeSeries}. */
@RunWith(JUnit4.class)
-public class TimeSeriesCumulativeTest {
+public class TimeSeriesTest {
@Rule public ExpectedException thrown = ExpectedException.none();
@@ -47,9 +47,9 @@ public class TimeSeriesCumulativeTest {
private static final Point POINT_2 = Point.create(VALUE_LONG, TIMESTAMP_3);
@Test
- public void testGet_TimeSeriesCumulative() {
- TimeSeriesCumulative cumulativeTimeSeries =
- TimeSeriesCumulative.create(
+ public void testGet_TimeSeries() {
+ TimeSeries cumulativeTimeSeries =
+ TimeSeries.create(
Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), TIMESTAMP_1);
assertThat(cumulativeTimeSeries.getStartTimestamp()).isEqualTo(TIMESTAMP_1);
assertThat(cumulativeTimeSeries.getLabelValues())
@@ -62,7 +62,7 @@ public class TimeSeriesCumulativeTest {
public void create_WithNullLabelValueList() {
thrown.expect(NullPointerException.class);
thrown.expectMessage(CoreMatchers.equalTo("labelValues"));
- TimeSeriesCumulative.create(null, Collections.<Point>emptyList(), TIMESTAMP_1);
+ TimeSeries.create(null, Collections.<Point>emptyList(), TIMESTAMP_1);
}
@Test
@@ -70,14 +70,14 @@ public class TimeSeriesCumulativeTest {
List<LabelValue> labelValues = Arrays.asList(LABEL_VALUE_1, null);
thrown.expect(NullPointerException.class);
thrown.expectMessage(CoreMatchers.equalTo("labelValue"));
- TimeSeriesCumulative.create(labelValues, Collections.<Point>emptyList(), TIMESTAMP_1);
+ TimeSeries.create(labelValues, Collections.<Point>emptyList(), TIMESTAMP_1);
}
@Test
public void create_WithNullPointList() {
thrown.expect(NullPointerException.class);
thrown.expectMessage(CoreMatchers.equalTo("points"));
- TimeSeriesCumulative.create(Collections.<LabelValue>emptyList(), null, TIMESTAMP_1);
+ TimeSeries.create(Collections.<LabelValue>emptyList(), null, TIMESTAMP_1);
}
@Test
@@ -85,28 +85,31 @@ public class TimeSeriesCumulativeTest {
List<Point> points = Arrays.asList(POINT_1, null);
thrown.expect(NullPointerException.class);
thrown.expectMessage(CoreMatchers.equalTo("point"));
- TimeSeriesCumulative.create(Collections.<LabelValue>emptyList(), points, TIMESTAMP_1);
+ TimeSeries.create(Collections.<LabelValue>emptyList(), points, TIMESTAMP_1);
}
@Test
public void testEquals() {
new EqualsTester()
.addEqualityGroup(
- TimeSeriesCumulative.create(
+ TimeSeries.create(
Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), TIMESTAMP_1),
- TimeSeriesCumulative.create(
+ TimeSeries.create(
Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), TIMESTAMP_1))
.addEqualityGroup(
- TimeSeriesCumulative.create(
+ TimeSeries.create(
+ Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), null),
+ TimeSeries.create(
+ Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), null))
+ .addEqualityGroup(
+ TimeSeries.create(
Arrays.asList(LABEL_VALUE_1, LABEL_VALUE_2), Arrays.asList(POINT_1), TIMESTAMP_2))
.addEqualityGroup(
- TimeSeriesCumulative.create(
- Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_1), TIMESTAMP_2))
+ TimeSeries.create(Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_1), TIMESTAMP_2))
.addEqualityGroup(
- TimeSeriesCumulative.create(
- Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_2), TIMESTAMP_2))
+ TimeSeries.create(Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_2), TIMESTAMP_2))
.addEqualityGroup(
- TimeSeriesCumulative.create(
+ TimeSeries.create(
Arrays.asList(LABEL_VALUE_1), Arrays.asList(POINT_1, POINT_2), TIMESTAMP_2))
.testEquals();
}
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 0a3c68b3..e6498066 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
@@ -27,8 +27,7 @@ import io.opencensus.metrics.Metric;
import io.opencensus.metrics.MetricDescriptor;
import io.opencensus.metrics.MetricDescriptor.Type;
import io.opencensus.metrics.Point;
-import io.opencensus.metrics.TimeSeriesGauge;
-import io.opencensus.metrics.TimeSeriesList;
+import io.opencensus.metrics.TimeSeries;
import io.opencensus.metrics.Value;
import java.util.Collections;
import java.util.List;
@@ -38,13 +37,10 @@ abstract class Gauge {
private final List<LabelValue> labelValues;
final Metric getMetric(Clock clock) {
- return Metric.create(
- metricDescriptor,
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(getTimeSeriesGauge(clock))));
+ return Metric.create(metricDescriptor, Collections.singletonList(getTimeSeries(clock)));
}
- abstract TimeSeriesGauge getTimeSeriesGauge(Clock clock);
+ abstract TimeSeries getTimeSeries(Clock clock);
static final class DoubleGauge<T> extends Gauge {
private final T obj;
@@ -66,11 +62,12 @@ abstract class Gauge {
}
@Override
- TimeSeriesGauge getTimeSeriesGauge(Clock clock) {
- return TimeSeriesGauge.create(
+ TimeSeries getTimeSeries(Clock clock) {
+ return TimeSeries.create(
getLabelValues(),
Collections.singletonList(
- Point.create(Value.doubleValue(function.applyAsDouble(obj)), clock.now())));
+ Point.create(Value.doubleValue(function.applyAsDouble(obj)), clock.now())),
+ null);
}
}
@@ -94,11 +91,12 @@ abstract class Gauge {
}
@Override
- TimeSeriesGauge getTimeSeriesGauge(Clock clock) {
- return TimeSeriesGauge.create(
+ TimeSeries getTimeSeries(Clock clock) {
+ return TimeSeries.create(
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 944cdc93..7368a161 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
@@ -37,10 +37,7 @@ import io.opencensus.metrics.Metric;
import io.opencensus.metrics.MetricDescriptor;
import io.opencensus.metrics.MetricDescriptor.Type;
import io.opencensus.metrics.Point;
-import io.opencensus.metrics.TimeSeriesCumulative;
-import io.opencensus.metrics.TimeSeriesGauge;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesCumulativeList;
-import io.opencensus.metrics.TimeSeriesList.TimeSeriesGaugeList;
+import io.opencensus.metrics.TimeSeries;
import io.opencensus.stats.Aggregation;
import io.opencensus.stats.AggregationData;
import io.opencensus.stats.Measure;
@@ -134,34 +131,18 @@ abstract class MutableViewData {
if (state == State.DISABLED) {
return null;
}
- // TODO(bdrutu): Refactor this after TimeSeriesGauge and TimeSeriesCumulative are combined.
Type type = metricDescriptor.getType();
- if (type == Type.GAUGE_INT64 || type == Type.GAUGE_DOUBLE) {
- List<TimeSeriesGauge> timeSeriesGauges = new ArrayList<TimeSeriesGauge>();
- for (Entry<List</*@Nullable*/ TagValue>, MutableAggregation> entry :
- tagValueAggregationMap.entrySet()) {
- List<LabelValue> labelValues = MetricUtils.tagValuesToLabelValues(entry.getKey());
- Point point = entry.getValue().toPoint(now);
- timeSeriesGauges.add(
- TimeSeriesGauge.create(labelValues, Collections.singletonList(point)));
- }
- return Metric.create(metricDescriptor, TimeSeriesGaugeList.create(timeSeriesGauges));
- } else {
- List<TimeSeriesCumulative> timeSeriesCumulatives = new ArrayList<TimeSeriesCumulative>();
- for (Entry<
- List<
- /*@Nullable*/
- TagValue>,
- MutableAggregation>
- entry : tagValueAggregationMap.entrySet()) {
- List<LabelValue> labelValues = MetricUtils.tagValuesToLabelValues(entry.getKey());
- Point point = entry.getValue().toPoint(now);
- timeSeriesCumulatives.add(
- TimeSeriesCumulative.create(labelValues, Collections.singletonList(point), start));
- }
- return Metric.create(
- metricDescriptor, TimeSeriesCumulativeList.create(timeSeriesCumulatives));
+ @javax.annotation.Nullable
+ Timestamp startTime = type == Type.GAUGE_INT64 || type == Type.GAUGE_DOUBLE ? null : start;
+ List<TimeSeries> timeSeriesList = new ArrayList<TimeSeries>();
+ for (Entry<List</*@Nullable*/ TagValue>, MutableAggregation> entry :
+ tagValueAggregationMap.entrySet()) {
+ List<LabelValue> labelValues = MetricUtils.tagValuesToLabelValues(entry.getKey());
+ Point point = entry.getValue().toPoint(now);
+ timeSeriesList.add(
+ TimeSeries.create(labelValues, Collections.singletonList(point), startTime));
}
+ return Metric.create(metricDescriptor, timeSeriesList);
}
@Override
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 1f6a1881..e1c17876 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
@@ -29,8 +29,7 @@ import io.opencensus.metrics.Metric;
import io.opencensus.metrics.MetricDescriptor;
import io.opencensus.metrics.MetricDescriptor.Type;
import io.opencensus.metrics.Point;
-import io.opencensus.metrics.TimeSeriesGauge;
-import io.opencensus.metrics.TimeSeriesList;
+import io.opencensus.metrics.TimeSeries;
import io.opencensus.metrics.Value;
import io.opencensus.testing.common.TestClock;
import java.util.Collections;
@@ -89,12 +88,12 @@ public class GaugeTest {
.isEqualTo(
Metric.create(
MetricDescriptor.create(NAME, DESCRIPTION, UNIT, Type.GAUGE_INT64, LABEL_KEYS),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- LABEL_VALUES,
- Collections.singletonList(
- Point.create(Value.longValue(OBJ.hashCode()), TEST_TIME)))))));
+ Collections.singletonList(
+ TimeSeries.create(
+ LABEL_VALUES,
+ Collections.singletonList(
+ Point.create(Value.longValue(OBJ.hashCode()), TEST_TIME)),
+ null))));
}
@Test
@@ -103,11 +102,11 @@ public class GaugeTest {
.isEqualTo(
Metric.create(
MetricDescriptor.create(NAME, DESCRIPTION, UNIT, Type.GAUGE_DOUBLE, LABEL_KEYS),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- LABEL_VALUES,
- Collections.singletonList(
- Point.create(Value.doubleValue(OBJ.hashCode()), TEST_TIME)))))));
+ Collections.singletonList(
+ TimeSeries.create(
+ LABEL_VALUES,
+ Collections.singletonList(
+ 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 fdab47aa..769efab2 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
@@ -27,8 +27,7 @@ import io.opencensus.metrics.Metric;
import io.opencensus.metrics.MetricDescriptor;
import io.opencensus.metrics.MetricDescriptor.Type;
import io.opencensus.metrics.Point;
-import io.opencensus.metrics.TimeSeriesGauge;
-import io.opencensus.metrics.TimeSeriesList;
+import io.opencensus.metrics.TimeSeries;
import io.opencensus.metrics.Value;
import io.opencensus.testing.common.TestClock;
import java.util.Collections;
@@ -159,12 +158,11 @@ public class MetricRegistryImplTest {
UNIT,
Type.GAUGE_DOUBLE,
Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
- Collections.singletonList(
- Point.create(Value.doubleValue(5.0), TEST_TIME)))))));
+ Collections.singletonList(
+ TimeSeries.create(
+ Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
+ Collections.singletonList(Point.create(Value.doubleValue(5.0), TEST_TIME)),
+ null))));
}
@Test
@@ -264,12 +262,11 @@ public class MetricRegistryImplTest {
UNIT,
Type.GAUGE_INT64,
Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
- Collections.singletonList(
- Point.create(Value.longValue(7), TEST_TIME)))))));
+ Collections.singletonList(
+ TimeSeries.create(
+ Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
+ Collections.singletonList(Point.create(Value.longValue(7), TEST_TIME)),
+ null))));
}
@Test
@@ -307,12 +304,11 @@ public class MetricRegistryImplTest {
UNIT,
Type.GAUGE_INT64,
Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
- Collections.singletonList(
- Point.create(Value.longValue(7), TEST_TIME)))))),
+ Collections.singletonList(
+ TimeSeries.create(
+ Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
+ Collections.singletonList(Point.create(Value.longValue(7), TEST_TIME)),
+ null))),
Metric.create(
MetricDescriptor.create(
NAME,
@@ -320,12 +316,11 @@ public class MetricRegistryImplTest {
UNIT,
Type.GAUGE_DOUBLE,
Collections.unmodifiableList(Collections.singletonList(LABEL_KEY))),
- TimeSeriesList.TimeSeriesGaugeList.create(
- Collections.singletonList(
- TimeSeriesGauge.create(
- Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
- Collections.singletonList(
- Point.create(Value.doubleValue(5.0), TEST_TIME)))))));
+ Collections.singletonList(
+ TimeSeries.create(
+ Collections.unmodifiableList(Collections.singletonList(LABEL_VALUES)),
+ Collections.singletonList(Point.create(Value.doubleValue(5.0), TEST_TIME)),
+ null))));
}
@Test