diff --git a/api/src/main/java/openconsensus/metrics/CounterDouble.java b/api/src/main/java/openconsensus/metrics/CounterDouble.java index fc967f1ed35..4ec983f14f3 100644 --- a/api/src/main/java/openconsensus/metrics/CounterDouble.java +++ b/api/src/main/java/openconsensus/metrics/CounterDouble.java @@ -41,7 +41,7 @@ * * void doWork() { * // Your code here. - * defaultPoint.add(10); + * defaultTimeSeries.add(10); * } * * } @@ -66,7 +66,7 @@ * * void doSomeWork() { * // Your code here. - * inboundPoint.set(15); + * inboundTimeSeries.set(15); * } * * } diff --git a/api/src/main/java/openconsensus/metrics/CounterLong.java b/api/src/main/java/openconsensus/metrics/CounterLong.java index 7867862c712..5fb59a13ad1 100644 --- a/api/src/main/java/openconsensus/metrics/CounterLong.java +++ b/api/src/main/java/openconsensus/metrics/CounterLong.java @@ -42,7 +42,7 @@ * * void doWork() { * // Your code here. - * defaultPoint.add(10); + * defaultTimeSeries.add(10); * } * * } @@ -67,7 +67,7 @@ * * void doSomeWork() { * // Your code here. - * inboundPoint.set(15); + * inboundTimeSeries.set(15); * } * * } diff --git a/api/src/main/java/openconsensus/metrics/GaugeDouble.java b/api/src/main/java/openconsensus/metrics/GaugeDouble.java index dcc9e8c7104..9853b3fd629 100644 --- a/api/src/main/java/openconsensus/metrics/GaugeDouble.java +++ b/api/src/main/java/openconsensus/metrics/GaugeDouble.java @@ -42,7 +42,7 @@ * * void doWork() { * // Your code here. - * defaultPoint.add(10); + * defaultTimeSeries.add(10); * } * * } @@ -67,7 +67,7 @@ * * void doSomeWork() { * // Your code here. - * inboundPoint.set(15); + * inboundTimeSeries.set(15); * } * * } diff --git a/api/src/main/java/openconsensus/stats/Measure.java b/api/src/main/java/openconsensus/metrics/Measure.java similarity index 99% rename from api/src/main/java/openconsensus/stats/Measure.java rename to api/src/main/java/openconsensus/metrics/Measure.java index e0658ad0f54..c812a6af1ae 100644 --- a/api/src/main/java/openconsensus/stats/Measure.java +++ b/api/src/main/java/openconsensus/metrics/Measure.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package openconsensus.stats; +package openconsensus.metrics; import javax.annotation.concurrent.ThreadSafe; diff --git a/api/src/main/java/openconsensus/stats/Measurement.java b/api/src/main/java/openconsensus/metrics/Measurement.java similarity index 96% rename from api/src/main/java/openconsensus/stats/Measurement.java rename to api/src/main/java/openconsensus/metrics/Measurement.java index 36464127295..ab0eedf5e55 100644 --- a/api/src/main/java/openconsensus/stats/Measurement.java +++ b/api/src/main/java/openconsensus/metrics/Measurement.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package openconsensus.stats; +package openconsensus.metrics; import javax.annotation.concurrent.Immutable; diff --git a/api/src/main/java/openconsensus/metrics/Meter.java b/api/src/main/java/openconsensus/metrics/Meter.java index 2be4aa5ab25..c38dc4ca014 100644 --- a/api/src/main/java/openconsensus/metrics/Meter.java +++ b/api/src/main/java/openconsensus/metrics/Meter.java @@ -16,7 +16,92 @@ package openconsensus.metrics; -/** Entry point fot metrics API, this object allows to create new {@link MetricRegistry}. */ +import java.util.List; +import openconsensus.tags.TagMap; +import openconsensus.trace.SpanContext; + +/** + * Meter is a simple, interface that allows users to record measurements (metrics). + * + *

There are two ways to record measurements: + * + *

+ * + *

Example usage for raw measurement: + * + *

{@code
+ * class MyClass {
+ *   private static final Meter meter = Metrics.getMeter();
+ *   private static final Measure cacheHit = meter.measureBuilder("cache_hit").build();
+ *
+ *   Response serverHandler(Request request) {
+ *     if (inCache(request)) {
+ *       meter.record(Collections.singletonList(cacheHit.createMeasurement(1)));
+ *       return fromCache(request);
+ *     }
+ *     ...  // do other work
+ *   }
+ *
+ * }
+ * }
+ * + *

Example usage for already aggregated metrics: + * + *

{@code
+ * public final void exportGarbageCollectorMetrics {
+ *   final CounterLong collectionMetric =
+ *       meter
+ *           .counterLongBuilder("collection")
+ *           .setDescription("Time spent in a given JVM garbage collector in milliseconds.")
+ *           .setUnit("ms")
+ *           .setLabelKeys(Collections.singletonList(GC))
+ *           .build();
+ *   collectionMetric.setCallback(
+ *       new Runnable() {
+ *         @Override
+ *         public void run() {
+ *           for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+ *             LabelValue gcName = LabelValue.create(gc.getName());
+ *             collectionMetric
+ *                 .getOrCreateTimeSeries(Collections.singletonList(gcName))
+ *                 .set(gc.getCollectionTime());
+ *           }
+ *         }
+ *       });
+ *   }
+ * }
+ * + *

Example usage for simple pre-defined aggregation metrics: + * + *

{@code
+ * class YourClass {
+ *
+ *   private static final Meter meter = Metrics.getMeter();
+ *   private static final MetricRegistry metricRegistry = meter.metricRegistryBuilder().build();
+ *
+ *   List labelKeys = Arrays.asList(LabelKey.create("Name", "desc"));
+ *   List labelValues = Arrays.asList(LabelValue.create("Inbound"));
+ *
+ *   GaugeDouble gauge = metricRegistry.addDoubleGauge("queue_size",
+ *                       "Pending jobs", "1", labelKeys);
+ *
+ *   // It is recommended to keep a reference of a TimeSeries.
+ *   GaugeDouble.TimeSeries inboundTimeSeries = gauge.getOrCreateTimeSeries(labelValues);
+ *
+ *   void doSomeWork() {
+ *      // Your code here.
+ *      inboundTimeSeries.add(15);
+ *   }
+ *
+ * }
+ * }
+ */ public interface Meter { /** @@ -24,5 +109,49 @@ public interface Meter { * * @return a new builder for a {@code MetricRegistry}. */ + // TODO: Consider to remove metric registry and move all methods in this class, or rename to a + // different name (maybe MetricsCollection). Also if an extra class is kept consider to move raw + // measurement API in it's own class as well. MetricRegistry.Builder metricRegistryBuilder(); + + /** + * Returns a new builder for a {@code Measure}. + * + * @param name Name of measure, as a {@code String}. Should be a ASCII string with a length no + * greater than 255 characters. + * @return a new builder for a {@code Measure}. + * @since 0.1.0 + */ + Measure.Builder measureBuilder(String name); + + /** + * Records all given measurements, with the current {@link + * openconsensus.tags.Tagger#getCurrentTagMap}. + * + * @param measurements the list of {@code Measurement}s to record. + * @since 0.1.0 + */ + void record(List measurements); + + /** + * Records all given measurements, with an explicit {@link TagMap}. + * + * @param measurements the list of {@code Measurement}s to record. + * @param tags the tags associated with the measurements. + * @since 0.1.0 + */ + void record(List measurements, TagMap tags); + + /** + * Records all given measurements, with an explicit {@link TagMap}. These measurements are + * associated with the given {@code SpanContext}. + * + * @param measurements the list of {@code Measurement}s to record. + * @param tags the tags associated with the measurements. + * @param spanContext the {@code SpanContext} that identifies the {@code Span} for which the + * measurements are associated with. + * @since 0.1.0 + */ + // TODO: Avoid tracing dependency and accept Attachments as in OpenCensus. + void record(List measurements, TagMap tags, SpanContext spanContext); } diff --git a/api/src/main/java/openconsensus/metrics/NoopMetrics.java b/api/src/main/java/openconsensus/metrics/NoopMetrics.java index 75ed14f09fd..fa637160b62 100644 --- a/api/src/main/java/openconsensus/metrics/NoopMetrics.java +++ b/api/src/main/java/openconsensus/metrics/NoopMetrics.java @@ -18,8 +18,13 @@ import java.util.List; import java.util.Map; +import javax.annotation.concurrent.Immutable; +import javax.annotation.concurrent.ThreadSafe; +import openconsensus.internal.StringUtils; import openconsensus.internal.Utils; import openconsensus.resource.Resource; +import openconsensus.tags.TagMap; +import openconsensus.trace.SpanContext; /** * No-op implementations of metrics classes. @@ -40,11 +45,42 @@ public static Meter newNoopMeter() { } private static final class NoopMeter implements Meter { + /* VisibleForTesting */ static final int NAME_MAX_LENGTH = 255; + private static final String ERROR_MESSAGE_INVALID_NAME = + "Name should be a ASCII string with a length no greater than " + + NAME_MAX_LENGTH + + " characters."; @Override public MetricRegistry.Builder metricRegistryBuilder() { return new NoopMetricCollection.Builder(); } + + @Override + public Measure.Builder measureBuilder(String name) { + Utils.checkArgument( + StringUtils.isPrintableString(name) && name.length() <= NAME_MAX_LENGTH, + ERROR_MESSAGE_INVALID_NAME); + return new NoopMeasure.NoopBuilder(); + } + + @Override + public void record(List measurements) { + Utils.checkNotNull(measurements, "measurements"); + } + + @Override + public void record(List measurements, TagMap tags) { + Utils.checkNotNull(measurements, "measurements"); + Utils.checkNotNull(tags, "tags"); + } + + @Override + public void record(List measurements, TagMap tags, SpanContext spanContext) { + Utils.checkNotNull(tags, "tags"); + Utils.checkNotNull(measurements, "measurements"); + Utils.checkNotNull(spanContext, "spanContext"); + } } private static final class NoopMetricCollection implements MetricRegistry { @@ -425,4 +461,63 @@ public CounterLong build() { } } } + + @ThreadSafe + private static final class NoopMeasure implements Measure { + private final Type type; + + private NoopMeasure(Type type) { + this.type = type; + } + + @Override + public Measurement createDoubleMeasurement(double value) { + if (type != Type.DOUBLE) { + throw new UnsupportedOperationException("This type can only create double measurement"); + } + Utils.checkArgument(value >= 0.0, "Unsupported negative values."); + return NoopMeasurement.INSTANCE; + } + + @Override + public Measurement createLongMeasurement(long value) { + if (type != Type.LONG) { + throw new UnsupportedOperationException("This type can only create long measurement"); + } + Utils.checkArgument(value >= 0, "Unsupported negative values."); + return NoopMeasurement.INSTANCE; + } + + private static final class NoopBuilder implements Measure.Builder { + private Type type = Type.DOUBLE; + + @Override + public Builder setDescription(String description) { + Utils.checkNotNull(description, "description"); + return this; + } + + @Override + public Builder setUnit(String unit) { + Utils.checkNotNull(unit, "unit"); + return this; + } + + @Override + public Builder setType(Type type) { + this.type = Utils.checkNotNull(type, "type"); + return this; + } + + @Override + public Measure build() { + return new NoopMeasure(type); + } + } + } + + @Immutable + private static final class NoopMeasurement implements Measurement { + private static final Measurement INSTANCE = new NoopMeasurement(); + } } diff --git a/api/src/main/java/openconsensus/stats/NoopStats.java b/api/src/main/java/openconsensus/stats/NoopStats.java deleted file mode 100644 index e98d83b1b6b..00000000000 --- a/api/src/main/java/openconsensus/stats/NoopStats.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2019, OpenConsensus 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 openconsensus.stats; - -import java.util.List; -import javax.annotation.concurrent.Immutable; -import javax.annotation.concurrent.ThreadSafe; -import openconsensus.internal.StringUtils; -import openconsensus.internal.Utils; -import openconsensus.tags.TagMap; -import openconsensus.trace.SpanContext; - -/** - * No-op implementations of stats classes. - * - * @since 0.1.0 - */ -public final class NoopStats { - - private NoopStats() {} - - /** - * Returns a {@code StatsRecorder} that is no-op implementation for {@link StatsRecorder}. - * - * @return a {@code StatsRecorder} that is no-op implementation for {@code StatsRecorder}. - * @since 0.1.0 - */ - public static StatsRecorder newNoopStatsRecorder() { - return new NoopStatsRecorder(); - } - - @Immutable - private static final class NoopStatsRecorder implements StatsRecorder { - /* VisibleForTesting */ static final int NAME_MAX_LENGTH = 255; - private static final String ERROR_MESSAGE_INVALID_NAME = - "Name should be a ASCII string with a length no greater than " - + NAME_MAX_LENGTH - + " characters."; - - @Override - public Measure.Builder measureBuilder(String name) { - Utils.checkArgument( - StringUtils.isPrintableString(name) && name.length() <= NAME_MAX_LENGTH, - ERROR_MESSAGE_INVALID_NAME); - return new NoopMeasure.NoopBuilder(); - } - - @Override - public void record(List measurements) { - Utils.checkNotNull(measurements, "measurements"); - } - - @Override - public void record(List measurements, TagMap tags) { - Utils.checkNotNull(measurements, "measurements"); - Utils.checkNotNull(tags, "tags"); - } - - @Override - public void record(List measurements, TagMap tags, SpanContext spanContext) { - Utils.checkNotNull(tags, "tags"); - Utils.checkNotNull(measurements, "measurements"); - Utils.checkNotNull(spanContext, "spanContext"); - } - } - - @ThreadSafe - private static final class NoopMeasure implements Measure { - private final Type type; - - private NoopMeasure(Type type) { - this.type = type; - } - - @Override - public Measurement createDoubleMeasurement(double value) { - if (type != Type.DOUBLE) { - throw new UnsupportedOperationException("This type can only create double measurement"); - } - Utils.checkArgument(value >= 0.0, "Unsupported negative values."); - return NoopMeasurement.INSTANCE; - } - - @Override - public Measurement createLongMeasurement(long value) { - if (type != Type.LONG) { - throw new UnsupportedOperationException("This type can only create long measurement"); - } - Utils.checkArgument(value >= 0, "Unsupported negative values."); - return NoopMeasurement.INSTANCE; - } - - private static final class NoopBuilder implements Measure.Builder { - private Type type = Type.DOUBLE; - - @Override - public Builder setDescription(String description) { - Utils.checkNotNull(description, "description"); - return this; - } - - @Override - public Builder setUnit(String unit) { - Utils.checkNotNull(unit, "unit"); - return this; - } - - @Override - public Builder setType(Type type) { - this.type = Utils.checkNotNull(type, "type"); - return this; - } - - @Override - public Measure build() { - return new NoopMeasure(type); - } - } - } - - @Immutable - private static final class NoopMeasurement implements Measurement { - private static final Measurement INSTANCE = new NoopMeasurement(); - } -} diff --git a/api/src/main/java/openconsensus/stats/Stats.java b/api/src/main/java/openconsensus/stats/Stats.java deleted file mode 100644 index 77d576f403e..00000000000 --- a/api/src/main/java/openconsensus/stats/Stats.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019, OpenConsensus 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 openconsensus.stats; - -/** - * Class for accessing the global {@link StatsRecorder}. - * - * @since 0.1.0 - */ -public final class Stats { - private static final StatsRecorder STATS_RECORDER = NoopStats.newNoopStatsRecorder(); - - /** - * Returns the global {@link StatsRecorder}. - * - * @return stats recorder. - * @since 0.1.0 - */ - public static StatsRecorder getStatsRecorder() { - return STATS_RECORDER; - } - - private Stats() {} -} diff --git a/api/src/main/java/openconsensus/stats/StatsRecorder.java b/api/src/main/java/openconsensus/stats/StatsRecorder.java deleted file mode 100644 index 899edf2888c..00000000000 --- a/api/src/main/java/openconsensus/stats/StatsRecorder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019, OpenConsensus 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 openconsensus.stats; - -import java.util.List; -import javax.annotation.concurrent.ThreadSafe; -import openconsensus.tags.TagMap; -import openconsensus.trace.SpanContext; - -/** - * Provides methods to record stats against tags. - * - * @since 0.1.0 - */ -@ThreadSafe -public interface StatsRecorder { - - /** - * Returns a new builder for a {@code Measure}. - * - * @param name Name of measure, as a {@code String}. Should be a ASCII string with a length no - * greater than 255 characters. - * @return a new builder for a {@code Measure}. - * @since 0.1.0 - */ - Measure.Builder measureBuilder(String name); - - /** - * Records all given measurements, with the current {@link - * openconsensus.tags.Tagger#getCurrentTagMap}. - * - * @param measurements the list of {@code Measurement}s to record. - * @since 0.1.0 - */ - void record(List measurements); - - /** - * Records all given measurements, with an explicit {@link TagMap}. - * - * @param measurements the list of {@code Measurement}s to record. - * @param tags the tags associated with the measurements. - * @since 0.1.0 - */ - void record(List measurements, TagMap tags); - - /** - * Records all given measurements, with an explicit {@link TagMap}. These measurements are - * associated with the given {@code SpanContext}. - * - * @param measurements the list of {@code Measurement}s to record. - * @param tags the tags associated with the measurements. - * @param spanContext the {@code SpanContext} that identifies the {@code Span} for which the - * measurements are associated with. - * @since 0.1.0 - */ - void record(List measurements, TagMap tags, SpanContext spanContext); -} diff --git a/api/src/main/java/openconsensus/stats/package-info.java b/api/src/main/java/openconsensus/stats/package-info.java deleted file mode 100644 index e47dfaeb4df..00000000000 --- a/api/src/main/java/openconsensus/stats/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2019, OpenConsensus 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. - */ - -/** API for stats recording. */ -// TODO: Add more details. -// TODO: Add code examples. -package openconsensus.stats; diff --git a/api/src/test/java/openconsensus/stats/MeasureTest.java b/api/src/test/java/openconsensus/metrics/MeasureTest.java similarity index 80% rename from api/src/test/java/openconsensus/stats/MeasureTest.java rename to api/src/test/java/openconsensus/metrics/MeasureTest.java index cb7aa41d368..035da65c372 100644 --- a/api/src/test/java/openconsensus/stats/MeasureTest.java +++ b/api/src/test/java/openconsensus/metrics/MeasureTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package openconsensus.stats; +package openconsensus.metrics; import java.util.Arrays; import org.junit.Rule; @@ -23,10 +23,10 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Tests for {@link Measure}. */ +/** Tests for {@link openconsensus.metrics.Measure}. */ @RunWith(JUnit4.class) public final class MeasureTest { - private static final StatsRecorder STATS_RECORDER = NoopStats.newNoopStatsRecorder(); + private static final Meter meter = NoopMetrics.newNoopMeter(); @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -36,18 +36,18 @@ public void preventTooLongMeasureName() { Arrays.fill(chars, 'a'); String longName = String.valueOf(chars); thrown.expect(IllegalArgumentException.class); - STATS_RECORDER.measureBuilder(longName).build(); + meter.measureBuilder(longName).build(); } @Test public void preventNonPrintableMeasureName() { thrown.expect(IllegalArgumentException.class); - STATS_RECORDER.measureBuilder("\2").build(); + meter.measureBuilder("\2").build(); } @Test public void preventNegativeValue() { - Measure myMeasure = STATS_RECORDER.measureBuilder("MyMeasure").build(); + Measure myMeasure = meter.measureBuilder("MyMeasure").build(); thrown.expect(IllegalArgumentException.class); myMeasure.createDoubleMeasurement(-5); } diff --git a/api/src/test/java/openconsensus/stats/NoopStatsTest.java b/api/src/test/java/openconsensus/metrics/NoopMeter.java similarity index 88% rename from api/src/test/java/openconsensus/stats/NoopStatsTest.java rename to api/src/test/java/openconsensus/metrics/NoopMeter.java index 9ca8edefe45..95370538087 100644 --- a/api/src/test/java/openconsensus/stats/NoopStatsTest.java +++ b/api/src/test/java/openconsensus/metrics/NoopMeter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package openconsensus.stats; +package openconsensus.metrics; import java.util.Collections; import java.util.Iterator; @@ -30,17 +30,17 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Unit tests for {@link NoopStats}. */ +/** Unit tests for {@link NoopMeter}. */ @RunWith(JUnit4.class) -public final class NoopStatsTest { +public final class NoopMeter { private static final Tag TAG = Tag.create( TagKey.create("key"), TagValue.create("value"), Tag.METADATA_UNLIMITED_PROPAGATION); - private static final StatsRecorder STATS_RECORDER = NoopStats.newNoopStatsRecorder(); + private static final Meter meter = NoopMetrics.newNoopMeter(); private static final Measure MEASURE = - STATS_RECORDER + meter .measureBuilder("my measure") .setDescription("description") .setType(Measure.Type.DOUBLE) @@ -69,7 +69,7 @@ public TagValue getTagValue(TagKey tagKey) { @Test public void noopStatsRecorder_Record() { List measurements = Collections.singletonList(MEASURE.createDoubleMeasurement(5)); - STATS_RECORDER.record(measurements, tagMap); + meter.record(measurements, tagMap); } // The NoopStatsRecorder should do nothing, so this test just checks that record doesn't throw an @@ -77,7 +77,7 @@ public void noopStatsRecorder_Record() { @Test public void noopStatsRecorder_RecordWithCurrentContext() { List measurements = Collections.singletonList(MEASURE.createDoubleMeasurement(6)); - STATS_RECORDER.record(measurements); + meter.record(measurements); } @Test @@ -85,6 +85,6 @@ public void noopStatsRecorder_Record_DisallowNulltagMap() { List measurements = Collections.singletonList(MEASURE.createDoubleMeasurement(6)); thrown.expect(NullPointerException.class); thrown.expectMessage("tags"); - STATS_RECORDER.record(measurements, null); + meter.record(measurements, null); } } diff --git a/api/src/test/java/openconsensus/stats/StatsTest.java b/api/src/test/java/openconsensus/stats/StatsTest.java deleted file mode 100644 index 4fa2b86a04f..00000000000 --- a/api/src/test/java/openconsensus/stats/StatsTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2019, OpenConsensus 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 openconsensus.stats; - -import static com.google.common.truth.Truth.assertThat; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for {@link Stats}. */ -@RunWith(JUnit4.class) -public final class StatsTest { - - @Test - public void defaultValues() { - assertThat(Stats.getStatsRecorder()).isInstanceOf(NoopStats.newNoopStatsRecorder().getClass()); - } -} diff --git a/sdk/src/main/java/openconsensus/sdk/stats/View.java b/sdk/src/main/java/openconsensus/sdk/stats/View.java index 20ac507fbb2..2da53bf34f8 100644 --- a/sdk/src/main/java/openconsensus/sdk/stats/View.java +++ b/sdk/src/main/java/openconsensus/sdk/stats/View.java @@ -23,7 +23,7 @@ import javax.annotation.concurrent.Immutable; import openconsensus.internal.StringUtils; import openconsensus.internal.Utils; -import openconsensus.stats.Measure; +import openconsensus.metrics.Measure; import openconsensus.tags.TagKey; /** diff --git a/sdk/src/main/java/openconsensus/sdk/stats/impl/MeasurementImpl.java b/sdk/src/main/java/openconsensus/sdk/stats/impl/MeasurementImpl.java index e2a63662db2..b0511303dd5 100644 --- a/sdk/src/main/java/openconsensus/sdk/stats/impl/MeasurementImpl.java +++ b/sdk/src/main/java/openconsensus/sdk/stats/impl/MeasurementImpl.java @@ -18,8 +18,8 @@ import com.google.auto.value.AutoValue; import javax.annotation.concurrent.Immutable; -import openconsensus.stats.Measure; -import openconsensus.stats.Measurement; +import openconsensus.metrics.Measure; +import openconsensus.metrics.Measurement; abstract class MeasurementImpl implements Measurement { /** @@ -31,7 +31,7 @@ abstract class MeasurementImpl implements Measurement { abstract Measure getMeasure(); /** - * Returns the double value for the {@link openconsensus.stats.Measurement}. + * Returns the double value for the {@link Measurement}. * *

This method should only be called with {@link MeasurementDouble}. * @@ -45,7 +45,7 @@ abstract class MeasurementImpl implements Measurement { } /** - * Returns the long value for the {@link openconsensus.stats.Measurement}. + * Returns the long value for the {@link Measurement}. * *

This method should only be called with {@link MeasurementLong}. * @@ -62,7 +62,7 @@ long getLongValue() { private MeasurementImpl() {} /** - * {@code double} typed {@link openconsensus.stats.Measurement}. + * {@code double} typed {@link Measurement}. * * @since 0.1.0 */ @@ -88,7 +88,7 @@ static MeasurementDouble create(Measure measure, double value) { } /** - * {@code long} typed {@link openconsensus.stats.Measurement}. + * {@code long} typed {@link Measurement}. * * @since 0.1.0 */