Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove labels keys from instruments #1121

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions api/src/main/java/io/opentelemetry/internal/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.opentelemetry.internal;

import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.Immutable;

Expand Down Expand Up @@ -115,23 +114,6 @@ public static <T> T checkNotNull(T arg, @javax.annotation.Nullable Object errorM
return arg;
}

/**
* Throws a {@link NullPointerException} if any of the list elements is null.
*
* @param list the argument list to check for null.
* @param errorMessage the message to use for the exception. Will be converted to a string using
* {@link String#valueOf(Object)}.
* @param <T> type of an argument to check.
*/
public static <T> void checkListElementNotNull(
List<T> list, @javax.annotation.Nullable Object errorMessage) {
for (T element : list) {
if (element == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
}
}

/**
* Throws a {@link NullPointerException} if any of the map elements is null.
*
Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -38,9 +37,6 @@ interface Builder extends Instrument.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
7 changes: 0 additions & 7 deletions api/src/main/java/io/opentelemetry/metrics/DefaultMeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.opentelemetry.internal.StringUtils;
import io.opentelemetry.internal.Utils;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.ThreadSafe;
Expand Down Expand Up @@ -406,12 +405,6 @@ public B setUnit(String unit) {
return getThis();
}

@Override
public B setLabelKeys(List<String> labelKeys) {
Utils.checkListElementNotNull(Utils.checkNotNull(labelKeys, "labelKeys"), "labelKey");
return getThis();
}

@Override
public B setConstantLabels(Map<String, String> constantLabels) {
Utils.checkMapKeysNotNull(
Expand Down
5 changes: 0 additions & 5 deletions api/src/main/java/io/opentelemetry/metrics/DoubleCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.DoubleCounter.BoundDoubleCounter;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -36,7 +35,6 @@
* .doubleCounterBuilder("processed_jobs")
* .setDescription("Processed jobs")
* .setUnit("1")
* .setLabelKeys(Collections.singletonList("Key"))
* .build();
* // It is recommended that the API user keep references to a Bound Counters.
* private static final BoundDoubleCounter someWorkBound =
Expand Down Expand Up @@ -99,9 +97,6 @@ interface Builder extends Counter.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/DoubleMeasure.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.DoubleMeasure.BoundDoubleMeasure;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -93,9 +92,6 @@ interface Builder extends Measure.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.DoubleObserver.ResultDoubleObserver;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -65,9 +64,6 @@ interface Builder extends Observer.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
11 changes: 0 additions & 11 deletions api/src/main/java/io/opentelemetry/metrics/Instrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -51,16 +50,6 @@ interface Builder {
*/
Builder setUnit(String unit);

/**
* Sets the list of label keys for the Instrument.
*
* <p>Default value is {@link Collections#emptyList()}
*
* @param labelKeys the list of label keys for the Instrument.
* @return this.
*/
Builder setLabelKeys(List<String> labelKeys);

/**
* Sets the map of constant labels (they will be added to all the Bound Instruments) for the
* Instrument.
Expand Down
5 changes: 0 additions & 5 deletions api/src/main/java/io/opentelemetry/metrics/LongCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.LongCounter.BoundLongCounter;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -36,7 +35,6 @@
* .longCounterBuilder("processed_jobs")
* .setDescription("Processed jobs")
* .setUnit("1")
* .setLabelKeys(Collections.singletonList("Key"))
* .build();
* // It is recommended that the API user keep a reference to a Bound Counter.
* private static final BoundLongCounter someWorkBound =
Expand Down Expand Up @@ -100,9 +98,6 @@ interface Builder extends Counter.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/LongMeasure.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.LongMeasure.BoundLongMeasure;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -93,9 +92,6 @@ interface Builder extends Measure.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/LongObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.LongObserver.ResultLongObserver;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -65,9 +64,6 @@ interface Builder extends Observer.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/Measure.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import io.opentelemetry.metrics.InstrumentWithBinding.BoundInstrument;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -38,9 +37,6 @@ interface Builder extends Instrument.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/io/opentelemetry/metrics/Observer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.opentelemetry.metrics;

import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -56,9 +55,6 @@ interface Builder extends Instrument.Builder {
@Override
Builder setUnit(String unit);

@Override
Builder setLabelKeys(List<String> labelKeys);

@Override
Builder setConstantLabels(Map<String, String> constantLabels);

Expand Down
34 changes: 2 additions & 32 deletions api/src/test/java/io/opentelemetry/metrics/DoubleCounterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.internal.StringUtils;
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;
Expand All @@ -35,7 +33,6 @@ public class DoubleCounterTest {
private static final String NAME = "name";
private static final String DESCRIPTION = "description";
private static final String UNIT = "1";
private static final List<String> LABEL_KEY = Collections.singletonList("key");

private final Meter meter = OpenTelemetry.getMeterProvider().get("counter_double_test");

Expand Down Expand Up @@ -70,39 +67,17 @@ public void preventNull_Unit() {
meter.doubleCounterBuilder("metric").setUnit(null).build();
}

@Test
public void preventNull_LabelKeys() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKeys");
meter.doubleCounterBuilder("metric").setLabelKeys(null).build();
}

@Test
public void preventNull_ConstantLabels() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("constantLabels");
meter.doubleCounterBuilder("metric").setConstantLabels(null).build();
}

@Test
public void preventNull_LabelKey() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKey");
meter
.doubleCounterBuilder("metric")
.setLabelKeys(Collections.<String>singletonList(null))
.build();
}

@Test
public void noopBind_WithBadLabelSet() {
DoubleCounter doubleCounter =
meter
.doubleCounterBuilder(NAME)
.setDescription(DESCRIPTION)
.setLabelKeys(LABEL_KEY)
.setUnit(UNIT)
.build();
meter.doubleCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("key/value");
doubleCounter.bind("key");
Expand All @@ -111,12 +86,7 @@ public void noopBind_WithBadLabelSet() {
@Test
public void doesNotThrow() {
DoubleCounter doubleCounter =
meter
.doubleCounterBuilder(NAME)
.setDescription(DESCRIPTION)
.setLabelKeys(LABEL_KEY)
.setUnit(UNIT)
.build();
meter.doubleCounterBuilder(NAME).setDescription(DESCRIPTION).setUnit(UNIT).build();
doubleCounter.bind().add(1.0);
}
}
18 changes: 0 additions & 18 deletions api/src/test/java/io/opentelemetry/metrics/DoubleMeasureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.opentelemetry.metrics;

import java.util.Arrays;
import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -61,23 +60,6 @@ public void preventNull_Unit() {
meter.doubleMeasureBuilder("metric").setUnit(null).build();
}

@Test
public void preventNull_LabelKeys() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKeys");
meter.doubleMeasureBuilder("metric").setLabelKeys(null).build();
}

@Test
public void preventNull_LabelKey() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKey");
meter
.doubleMeasureBuilder("metric")
.setLabelKeys(Collections.<String>singletonList(null))
.build();
}

@Test
public void preventNull_ConstantLabels() {
thrown.expect(NullPointerException.class);
Expand Down
18 changes: 0 additions & 18 deletions api/src/test/java/io/opentelemetry/metrics/DoubleObserverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.internal.StringUtils;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -63,23 +62,6 @@ public void preventNull_Unit() {
meter.doubleObserverBuilder("metric").setUnit(null).build();
}

@Test
public void preventNull_LabelKeys() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKeys");
meter.doubleObserverBuilder("metric").setLabelKeys(null).build();
}

@Test
public void preventNull_LabelKey() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("labelKey");
meter
.doubleObserverBuilder("metric")
.setLabelKeys(Collections.<String>singletonList(null))
.build();
}

@Test
public void preventNull_ConstantLabels() {
thrown.expect(NullPointerException.class);
Expand Down
Loading