Replace LabelConsumer with BiConsumer (#1980)
This commit is contained in:
parent
db93a841ed
commit
37cce8dbca
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.api.common;
|
||||
|
||||
/** Convenience interface for consuming {@link Labels}. */
|
||||
@FunctionalInterface
|
||||
public interface LabelConsumer {
|
||||
void accept(String key, String value);
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.api.common;
|
|||
import com.google.auto.value.AutoValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/** An immutable container for labels, which are pairs of {@link String}. */
|
||||
|
|
@ -16,7 +17,7 @@ public abstract class Labels extends ImmutableKeyValuePairs<String, String> {
|
|||
|
||||
private static final Labels EMPTY = Labels.builder().build();
|
||||
|
||||
public abstract void forEach(LabelConsumer consumer);
|
||||
public abstract void forEach(BiConsumer<String, String> consumer);
|
||||
|
||||
@AutoValue
|
||||
@Immutable
|
||||
|
|
@ -27,7 +28,7 @@ public abstract class Labels extends ImmutableKeyValuePairs<String, String> {
|
|||
abstract List<Object> data();
|
||||
|
||||
@Override
|
||||
public void forEach(LabelConsumer consumer) {
|
||||
public void forEach(BiConsumer<String, String> consumer) {
|
||||
List<Object> data = data();
|
||||
for (int i = 0; i < data.size(); i += 2) {
|
||||
consumer.accept((String) data.get(i), (String) data.get(i + 1));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package io.opentelemetry.exporters.prometheus;
|
|||
|
||||
import static io.prometheus.client.Collector.doubleToGoString;
|
||||
|
||||
import io.opentelemetry.api.common.LabelConsumer;
|
||||
import io.opentelemetry.api.common.Labels;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData.DoublePoint;
|
||||
|
|
@ -22,6 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Util methods to convert OpenTelemetry Metrics data models to Prometheus data models.
|
||||
|
|
@ -117,7 +117,7 @@ final class MetricAdapter {
|
|||
return Collector.sanitizeMetricName(labelKey);
|
||||
}
|
||||
|
||||
private static final class Consumer implements LabelConsumer {
|
||||
private static final class Consumer implements BiConsumer<String, String> {
|
||||
final List<String> labelNames;
|
||||
final List<String> labelValues;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue