Skip to content

Commit db3110e

Browse files
committed
Add other bound instrument interfaces
1 parent 07ce2d7 commit db3110e

23 files changed

Lines changed: 539 additions & 0 deletions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.DoubleCounter;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link DoubleCounter} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedDoubleCounter#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #add(double)} calls
18+
* record directly without the per-recording attribute processing and map lookup that {@link
19+
* DoubleCounter#add(double, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundDoubleCounter {
24+
25+
/**
26+
* Records a value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The increment amount. MUST be non-negative.
32+
*/
33+
void add(double value);
34+
35+
/**
36+
* Records a value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The increment amount. MUST be non-negative.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void add(double value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.DoubleGauge;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link DoubleGauge} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedDoubleGauge#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #set(double)} calls
18+
* record directly without the per-recording attribute processing and map lookup that {@link
19+
* DoubleGauge#set(double, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundDoubleGauge {
24+
25+
/**
26+
* Records the gauge value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The current gauge value.
32+
*/
33+
void set(double value);
34+
35+
/**
36+
* Records the gauge value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The current gauge value.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void set(double value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.DoubleHistogram;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link DoubleHistogram} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedDoubleHistogram#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #record(double)} calls
18+
* record directly without the per-recording attribute processing and map lookup that {@link
19+
* DoubleHistogram#record(double, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundDoubleHistogram {
24+
25+
/**
26+
* Records a value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The amount of the measurement. MUST be non-negative.
32+
*/
33+
void record(double value);
34+
35+
/**
36+
* Records a value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The amount of the measurement. MUST be non-negative.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void record(double value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.DoubleUpDownCounter;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link DoubleUpDownCounter} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedDoubleUpDownCounter#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #add(double)} calls
18+
* record directly without the per-recording attribute processing and map lookup that {@link
19+
* DoubleUpDownCounter#add(double, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundDoubleUpDownCounter {
24+
25+
/**
26+
* Records a value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The increment amount. May be positive, negative or zero.
32+
*/
33+
void add(double value);
34+
35+
/**
36+
* Records a value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The increment amount. May be positive, negative or zero.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void add(double value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.LongGauge;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link LongGauge} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedLongGauge#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #set(long)} calls record
18+
* directly without the per-recording attribute processing and map lookup that {@link
19+
* LongGauge#set(long, Attributes)} performs. This is useful when the set of attribute combinations
20+
* is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundLongGauge {
24+
25+
/**
26+
* Records the gauge value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The current gauge value.
32+
*/
33+
void set(long value);
34+
35+
/**
36+
* Records the gauge value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The current gauge value.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void set(long value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.LongHistogram;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link LongHistogram} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedLongHistogram#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #record(long)} calls
18+
* record directly without the per-recording attribute processing and map lookup that {@link
19+
* LongHistogram#record(long, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundLongHistogram {
24+
25+
/**
26+
* Records a value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The amount of the measurement. MUST be non-negative.
32+
*/
33+
void record(long value);
34+
35+
/**
36+
* Records a value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The amount of the measurement. MUST be non-negative.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void record(long value, Context context);
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.metrics;
7+
8+
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.api.metrics.LongUpDownCounter;
10+
import io.opentelemetry.context.Context;
11+
import javax.annotation.concurrent.ThreadSafe;
12+
13+
/**
14+
* A {@link LongUpDownCounter} bound to a fixed set of {@link Attributes}, obtained via {@link
15+
* ExtendedLongUpDownCounter#bind(Attributes)}.
16+
*
17+
* <p>Binding resolves the underlying timeseries once, so subsequent {@link #add(long)} calls record
18+
* directly without the per-recording attribute processing and map lookup that {@link
19+
* LongUpDownCounter#add(long, Attributes)} performs. This is useful when the set of attribute
20+
* combinations is known ahead of time and the same series is recorded to repeatedly.
21+
*/
22+
@ThreadSafe
23+
public interface BoundLongUpDownCounter {
24+
25+
/**
26+
* Records a value against the bound attributes.
27+
*
28+
* <p>Note: This may use {@code Context.current()} to pull the context associated with this
29+
* measurement.
30+
*
31+
* @param value The increment amount. May be positive, negative or zero.
32+
*/
33+
void add(long value);
34+
35+
/**
36+
* Records a value against the bound attributes, with an explicit {@link Context}.
37+
*
38+
* @param value The increment amount. May be positive, negative or zero.
39+
* @param context The explicit context to associate with this measurement.
40+
*/
41+
void add(long value, Context context);
42+
}

0 commit comments

Comments
 (0)