aboutsummaryrefslogtreecommitdiff
path: root/impl_core/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'impl_core/src/main/java/io')
-rw-r--r--impl_core/src/main/java/io/opencensus/implcore/metrics/DoubleGaugeImpl.java7
-rw-r--r--impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java109
-rw-r--r--impl_core/src/main/java/io/opencensus/implcore/metrics/LongGaugeImpl.java7
3 files changed, 6 insertions, 117 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/metrics/DoubleGaugeImpl.java b/impl_core/src/main/java/io/opencensus/implcore/metrics/DoubleGaugeImpl.java
index d329091e..86b3512d 100644
--- a/impl_core/src/main/java/io/opencensus/implcore/metrics/DoubleGaugeImpl.java
+++ b/impl_core/src/main/java/io/opencensus/implcore/metrics/DoubleGaugeImpl.java
@@ -70,8 +70,7 @@ public final class DoubleGaugeImpl extends DoubleGauge implements Meter {
List<LabelValue> labelValuesCopy =
Collections.unmodifiableList(
- new ArrayList<LabelValue>(
- checkNotNull(labelValues, "labelValues should not be null.")));
+ new ArrayList<LabelValue>(checkNotNull(labelValues, "labelValues")));
return registerTimeSeries(labelValuesCopy);
}
@@ -87,7 +86,7 @@ public final class DoubleGaugeImpl extends DoubleGauge implements Meter {
@Override
public synchronized void removeTimeSeries(List<LabelValue> labelValues) {
- checkNotNull(labelValues, "labelValues should not be null.");
+ checkNotNull(labelValues, "labelValues");
Map<List<LabelValue>, PointImpl> registeredPointsCopy =
new LinkedHashMap<List<LabelValue>, PointImpl>(registeredPoints);
@@ -112,7 +111,7 @@ public final class DoubleGaugeImpl extends DoubleGauge implements Meter {
}
checkArgument(labelKeysSize == labelValues.size(), "Incorrect number of labels.");
- Utils.checkListElementNotNull(labelValues, "labelValues element should not be null.");
+ Utils.checkListElementNotNull(labelValues, "labelValue element should not be null.");
PointImpl newPoint = new PointImpl(labelValues);
// Updating the map of points happens under a lock to avoid multiple add operations
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
deleted file mode 100644
index e52fcff5..00000000
--- a/impl_core/src/main/java/io/opencensus/implcore/metrics/Gauge.java
+++ /dev/null
@@ -1,109 +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.implcore.metrics;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.opencensus.common.Clock;
-import io.opencensus.common.ToDoubleFunction;
-import io.opencensus.common.ToLongFunction;
-import io.opencensus.metrics.LabelKey;
-import io.opencensus.metrics.LabelValue;
-import io.opencensus.metrics.export.Metric;
-import io.opencensus.metrics.export.MetricDescriptor;
-import io.opencensus.metrics.export.MetricDescriptor.Type;
-import io.opencensus.metrics.export.Point;
-import io.opencensus.metrics.export.TimeSeries;
-import io.opencensus.metrics.export.Value;
-import java.util.Collections;
-import java.util.List;
-
-abstract class Gauge {
- private final MetricDescriptor metricDescriptor;
- private final List<LabelValue> labelValues;
-
- final Metric getMetric(Clock clock) {
- return Metric.createWithOneTimeSeries(metricDescriptor, getTimeSeries(clock));
- }
-
- abstract TimeSeries getTimeSeries(Clock clock);
-
- static final class DoubleGauge<T> extends Gauge {
- private final T obj;
- private final ToDoubleFunction<T> function;
-
- DoubleGauge(
- String name,
- String description,
- String unit,
- List<LabelKey> labelKeys,
- List<LabelValue> labelValues,
- T obj,
- ToDoubleFunction<T> function) {
- super(
- MetricDescriptor.create(name, description, unit, Type.GAUGE_DOUBLE, labelKeys),
- labelValues);
- this.obj = obj;
- this.function = function;
- }
-
- @Override
- TimeSeries getTimeSeries(Clock clock) {
- return TimeSeries.createWithOnePoint(
- getLabelValues(),
- Point.create(Value.doubleValue(function.applyAsDouble(obj)), clock.now()),
- null);
- }
- }
-
- static final class LongGauge<T> extends Gauge {
- private final T obj;
- private final ToLongFunction<T> function;
-
- LongGauge(
- String name,
- String description,
- String unit,
- List<LabelKey> labelKeys,
- List<LabelValue> labelValues,
- T obj,
- ToLongFunction<T> function) {
- super(
- MetricDescriptor.create(name, description, unit, Type.GAUGE_INT64, labelKeys),
- labelValues);
- this.obj = obj;
- this.function = function;
- }
-
- @Override
- TimeSeries getTimeSeries(Clock clock) {
- return TimeSeries.createWithOnePoint(
- getLabelValues(),
- Point.create(Value.longValue(function.applyAsLong(obj)), clock.now()),
- null);
- }
- }
-
- List<LabelValue> getLabelValues() {
- return labelValues;
- }
-
- Gauge(MetricDescriptor metricDescriptor, List<LabelValue> labelValues) {
- this.metricDescriptor = checkNotNull(metricDescriptor, "metricDescriptor");
- this.labelValues = Collections.unmodifiableList(labelValues);
- }
-}
diff --git a/impl_core/src/main/java/io/opencensus/implcore/metrics/LongGaugeImpl.java b/impl_core/src/main/java/io/opencensus/implcore/metrics/LongGaugeImpl.java
index 64cb3200..f158e656 100644
--- a/impl_core/src/main/java/io/opencensus/implcore/metrics/LongGaugeImpl.java
+++ b/impl_core/src/main/java/io/opencensus/implcore/metrics/LongGaugeImpl.java
@@ -70,8 +70,7 @@ public final class LongGaugeImpl extends LongGauge implements Meter {
List<LabelValue> labelValuesCopy =
Collections.unmodifiableList(
- new ArrayList<LabelValue>(
- checkNotNull(labelValues, "labelValues should not be null.")));
+ new ArrayList<LabelValue>(checkNotNull(labelValues, "labelValues")));
return registerTimeSeries(labelValuesCopy);
}
@@ -87,7 +86,7 @@ public final class LongGaugeImpl extends LongGauge implements Meter {
@Override
public synchronized void removeTimeSeries(List<LabelValue> labelValues) {
- checkNotNull(labelValues, "labelValues should not be null.");
+ checkNotNull(labelValues, "labelValues");
Map<List<LabelValue>, PointImpl> registeredPointsCopy =
new LinkedHashMap<List<LabelValue>, PointImpl>(registeredPoints);
@@ -112,7 +111,7 @@ public final class LongGaugeImpl extends LongGauge implements Meter {
}
checkArgument(labelKeysSize == labelValues.size(), "Incorrect number of labels.");
- Utils.checkListElementNotNull(labelValues, "labelValues element should not be null.");
+ Utils.checkListElementNotNull(labelValues, "labelValue element should not be null.");
PointImpl newPoint = new PointImpl(labelValues);
// Updating the map of points happens under a lock to avoid multiple add operations