Skip to content
Draft
1 change: 1 addition & 0 deletions api/all/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
annotationProcessor("com.google.auto.value:auto-value")

testImplementation(project(":api:testing-internal"))
testImplementation(project(":sdk:testing"))

testImplementation("edu.berkeley.cs.jqf:jqf-fuzz")
testImplementation("com.google.guava:guava-testlib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class DefaultMeter implements Meter {
new NoopObservableDoubleMeasurement();
private static final ObservableLongMeasurement NOOP_OBSERVABLE_LONG_MEASUREMENT =
new NoopObservableLongMeasurement();
private static final DoubleCounterOp NOOP_DOUBLE_COUNTER_OP = value -> {};
private static final LongCounterOp NOOP_LONG_COUNTER_OP = value -> {};
private static final DoubleUpDownCounterOp NOOP_DOUBLE_UP_DOWN_COUNTER_OP = value -> {};
private static final LongUpDownCounterOp NOOP_LONG_UP_DOWN_COUNTER_OP = value -> {};
private static final DoubleHistogramOp NOOP_DOUBLE_HISTOGRAM_OP = value -> {};
private static final LongHistogramOp NOOP_LONG_HISTOGRAM_OP = value -> {};
private static final DoubleGaugeOp NOOP_DOUBLE_GAUGE_OP = value -> {};
private static final LongGaugeOp NOOP_LONG_GAUGE_OP = value -> {};

static Meter getInstance() {
return INSTANCE;
Expand Down Expand Up @@ -75,6 +83,11 @@ public boolean isEnabled() {
@Override
public void add(long value, Attributes attributes, Context context) {}

@Override
public LongCounterOp bind(Attributes attributes) {
return NOOP_LONG_COUNTER_OP;
}

@Override
public void add(long value, Attributes attributes) {}

Expand All @@ -91,6 +104,11 @@ public boolean isEnabled() {
@Override
public void add(double value, Attributes attributes, Context context) {}

@Override
public DoubleCounterOp bind(Attributes attributes) {
return NOOP_DOUBLE_COUNTER_OP;
}

@Override
public void add(double value, Attributes attributes) {}

Expand Down Expand Up @@ -182,6 +200,11 @@ public void add(long value, Attributes attributes) {}

@Override
public void add(long value) {}

@Override
public LongUpDownCounterOp bind(Attributes attributes) {
return NOOP_LONG_UP_DOWN_COUNTER_OP;
}
}

private static class NoopDoubleUpDownCounter implements DoubleUpDownCounter {
Expand All @@ -198,6 +221,11 @@ public void add(double value, Attributes attributes) {}

@Override
public void add(double value) {}

@Override
public DoubleUpDownCounterOp bind(Attributes attributes) {
return NOOP_DOUBLE_UP_DOWN_COUNTER_OP;
}
}

private static class NoopLongUpDownCounterBuilder implements LongUpDownCounterBuilder {
Expand Down Expand Up @@ -286,6 +314,11 @@ public void record(double value, Attributes attributes) {}

@Override
public void record(double value) {}

@Override
public DoubleHistogramOp bind(Attributes attributes) {
return NOOP_DOUBLE_HISTOGRAM_OP;
}
}

private static class NoopLongHistogram implements LongHistogram {
Expand All @@ -302,6 +335,11 @@ public void record(long value, Attributes attributes) {}

@Override
public void record(long value) {}

@Override
public LongHistogramOp bind(Attributes attributes) {
return NOOP_LONG_HISTOGRAM_OP;
}
}

private static class NoopDoubleHistogramBuilder implements DoubleHistogramBuilder {
Expand Down Expand Up @@ -400,6 +438,11 @@ public void set(double value, Attributes attributes) {}

@Override
public void set(double value, Attributes attributes, Context context) {}

@Override
public DoubleGaugeOp bind(Attributes attributes) {
return NOOP_DOUBLE_GAUGE_OP;
}
}

private static class NoopLongGaugeBuilder implements LongGaugeBuilder {
Expand Down Expand Up @@ -446,6 +489,11 @@ public void set(long value, Attributes attributes) {}

@Override
public void set(long value, Attributes attributes, Context context) {}

@Override
public LongGaugeOp bind(Attributes attributes) {
return NOOP_LONG_GAUGE_OP;
}
}

private static class NoopObservableDoubleMeasurement implements ObservableDoubleMeasurement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @since 1.10.0
*/
@ThreadSafe
public interface DoubleCounter {
public interface DoubleCounter extends DoubleCounterOp {

/**
* Returns {@code true} if the counter is enabled.
Expand All @@ -31,16 +31,6 @@ default boolean isEnabled() {
return true;
}

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The increment amount. MUST be non-negative.
*/
void add(double value);

/**
* Records a value with a set of attributes.
*
Expand All @@ -60,4 +50,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(double value, Attributes attributes, Context context);

DoubleCounterOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A Counter instrument that records {@code double} values. */
@ThreadSafe
public interface DoubleCounterOp {

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The increment amount. MUST be non-negative.
*/
void add(double value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void set(double value, Attributes attributes, Context context);

DoubleGaugeOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A gauge instrument that synchronously records {@code double} values. */
@ThreadSafe
public interface DoubleGaugeOp {

/**
* Set the gauge value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The current gauge value.
*/
void set(double value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void record(double value, Attributes attributes, Context context);

DoubleHistogramOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A Histogram instrument that records {@code double} values. */
@ThreadSafe
public interface DoubleHistogramOp {

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The amount of the measurement. MUST be non-negative.
*/
void record(double value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(double value, Attributes attributes, Context context);

DoubleUpDownCounterOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** An UpDownCounter instrument that records {@code double} values. */
@ThreadSafe
public interface DoubleUpDownCounterOp {

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The increment amount. May be positive, negative or zero.
*/
void add(double value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @since 1.10.0
*/
@ThreadSafe
public interface LongCounter {
public interface LongCounter extends LongCounterOp {

/**
* Returns {@code true} if the counter is enabled.
Expand All @@ -31,16 +31,6 @@ default boolean isEnabled() {
return true;
}

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The increment amount. MUST be non-negative.
*/
void add(long value);

/**
* Records a value with a set of attributes.
*
Expand All @@ -60,4 +50,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(long value, Attributes attributes, Context context);

LongCounterOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A Counter instrument that records {@code long} values. */
@ThreadSafe
public interface LongCounterOp {

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The increment amount. MUST be non-negative.
*/
void add(long value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void set(long value, Attributes attributes, Context context);

LongGaugeOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A gauge instrument that synchronously records {@code long} values. */
@ThreadSafe
public interface LongGaugeOp {

/**
* Set the gauge value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The current gauge value.
*/
void set(long value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void record(long value, Attributes attributes, Context context);

LongHistogramOp bind(Attributes attributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.api.metrics;

import javax.annotation.concurrent.ThreadSafe;

/** A Histogram instrument that records {@code long} values. */
@ThreadSafe
public interface LongHistogramOp {

/**
* Records a value.
*
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
* measurement.
*
* @param value The amount of the measurement. MUST be non-negative.
*/
void record(long value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(long value, Attributes attributes, Context context);

LongUpDownCounterOp bind(Attributes attributes);
}
Loading
Loading