Skip to content

Commit

Permalink
Remove labels keys from instruments
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Apr 17, 2020
1 parent c32c776 commit 5c510e8
Show file tree
Hide file tree
Showing 37 changed files with 13 additions and 291 deletions.
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

0 comments on commit 5c510e8

Please sign in to comment.