Skip to content

Commit

Permalink
Refactor advice API (#5848)
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-berg authored Oct 6, 2023
1 parent 533c30a commit 92abcb8
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 268 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.DoubleCounterBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link DoubleCounterBuilder} with experimental APIs. */
public interface ExtendedDoubleCounterBuilder extends DoubleCounterBuilder {

/** Specify advice for counter implementations. */
default DoubleCounterBuilder setAdvice(Consumer<DoubleCounterAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this counter.
*/
default ExtendedDoubleCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.DoubleGaugeBuilder;
import java.util.List;
import java.util.function.Consumer;

/** Extended {@link DoubleGaugeBuilder} with experimental APIs. */
Expand All @@ -22,8 +24,11 @@ public interface ExtendedDoubleGaugeBuilder extends DoubleGaugeBuilder {
*/
DoubleGauge build();

/** Specify advice for gauge implementations. */
default DoubleGaugeBuilder setAdvice(Consumer<DoubleGaugeAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this gauge.
*/
default ExtendedDoubleGaugeBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link DoubleHistogramBuilder} with experimental APIs. */
public interface ExtendedDoubleHistogramBuilder extends DoubleHistogramBuilder {

/** Specify advice for histogram implementations. */
default DoubleHistogramBuilder setAdvice(
Consumer<DoubleHistogramAdviceConfigurer> adviceConsumer) {
/**
* Specify the explicit bucket buckets boundaries advice, which suggests the recommended set of
* explicit bucket boundaries for this histogram.
*/
default ExtendedDoubleHistogramBuilder setExplicitBucketBoundariesAdvice(
List<Double> bucketBoundaries) {
return this;
}

/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this histogram.
*/
default ExtendedDoubleHistogramBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.DoubleUpDownCounterBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link DoubleUpDownCounterBuilder} with experimental APIs. */
public interface ExtendedDoubleUpDownCounterBuilder extends DoubleUpDownCounterBuilder {

/** Specify advice for up down counter implementations. */
default DoubleUpDownCounterBuilder setAdvice(
Consumer<DoubleUpDownCounterAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this up down counter.
*/
default ExtendedDoubleUpDownCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.LongCounterBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link LongCounterBuilder} with experimental APIs. */
public interface ExtendedLongCounterBuilder extends LongCounterBuilder {

/** Specify advice for counter implementations. */
default LongCounterBuilder setAdvice(Consumer<LongCounterAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this counter.
*/
default ExtendedLongCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.LongGaugeBuilder;
import java.util.List;
import java.util.function.Consumer;

/** Extended {@link LongGaugeBuilder} with experimental APIs. */
Expand All @@ -22,8 +24,11 @@ public interface ExtendedLongGaugeBuilder extends LongGaugeBuilder {
*/
LongGauge build();

/** Specify advice for gauge implementations. */
default LongGaugeBuilder setAdvice(Consumer<LongGaugeAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this gauge.
*/
default ExtendedLongGaugeBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.LongHistogramBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link LongHistogramBuilder} with experimental APIs. */
public interface ExtendedLongHistogramBuilder extends LongHistogramBuilder {

/** Specify advice for histogram implementations. */
default LongHistogramBuilder setAdvice(Consumer<LongHistogramAdviceConfigurer> adviceConsumer) {
/**
* Specify the explicit bucket buckets boundaries advice, which suggests the recommended set of
* explicit bucket boundaries for this histogram.
*/
default ExtendedLongHistogramBuilder setExplicitBucketBoundariesAdvice(
List<Long> bucketBoundaries) {
return this;
}

/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this histogram.
*/
default ExtendedLongHistogramBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

package io.opentelemetry.extension.incubator.metrics;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.metrics.LongUpDownCounterBuilder;
import java.util.function.Consumer;
import java.util.List;

/** Extended {@link LongUpDownCounterBuilder} with experimental APIs. */
public interface ExtendedLongUpDownCounterBuilder extends LongUpDownCounterBuilder {

/** Specify advice for up down counter implementations. */
default LongUpDownCounterBuilder setAdvice(
Consumer<LongUpDownCounterAdviceConfigurer> adviceConsumer) {
/**
* Specify the attribute advice, which suggests the recommended set of attribute keys to be used
* for this up down counter.
*/
default ExtendedLongUpDownCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
return this;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.DoubleCounter;
import io.opentelemetry.api.metrics.DoubleCounterBuilder;
import io.opentelemetry.api.metrics.ObservableDoubleCounter;
import io.opentelemetry.api.metrics.ObservableDoubleMeasurement;
import io.opentelemetry.context.Context;
import io.opentelemetry.extension.incubator.metrics.DoubleCounterAdviceConfigurer;
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleCounterBuilder;
import io.opentelemetry.sdk.internal.ThrottlingLogger;
import io.opentelemetry.sdk.metrics.internal.descriptor.Advice;
Expand Down Expand Up @@ -61,7 +59,7 @@ public void add(double increment) {

static final class SdkDoubleCounterBuilder
extends AbstractInstrumentBuilder<SdkDoubleCounterBuilder>
implements ExtendedDoubleCounterBuilder, DoubleCounterAdviceConfigurer {
implements ExtendedDoubleCounterBuilder {

SdkDoubleCounterBuilder(
MeterProviderSharedState meterProviderSharedState,
Expand All @@ -86,12 +84,6 @@ protected SdkDoubleCounterBuilder getThis() {
return this;
}

@Override
public DoubleCounterBuilder setAdvice(Consumer<DoubleCounterAdviceConfigurer> adviceConsumer) {
adviceConsumer.accept(this);
return this;
}

@Override
public SdkDoubleCounter build() {
return buildSynchronousInstrument(SdkDoubleCounter::new);
Expand All @@ -109,7 +101,7 @@ public ObservableDoubleMeasurement buildObserver() {
}

@Override
public DoubleCounterAdviceConfigurer setAttributes(List<AttributeKey<?>> attributes) {
public ExtendedDoubleCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
adviceBuilder.setAttributes(attributes);
return this;
}
Expand Down
Loading

0 comments on commit 92abcb8

Please sign in to comment.