Skip to content

Commit 4da6ca0

Browse files
committed
PR feedback
1 parent 71d75b2 commit 4da6ca0

4 files changed

Lines changed: 20 additions & 33 deletions

File tree

sdk/all/src/jmh/java/io/opentelemetry/sdk/MetricRecordBenchmark.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ public static class BenchmarkState {
119119

120120
// Whether to record through bound instruments (Extended*#bind(Attributes)), which resolve the
121121
// timeseries once up front, or unbound instruments, which look up the timeseries by Attributes
122-
// on every record.
123-
@Param({"false", "true"})
124-
boolean bound;
122+
// on every record. Uncomment to evaluate.
123+
// @Param({"false", "true"})
124+
// boolean bound;
125+
boolean bound = false;
125126

126127
// The following parameters are excluded from the benchmark to reduce combinatorial explosion
127128
// but can optionally be enabled for adhoc evaluation.

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/CumulativeSynchronousMetricStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private final class CumulativeBoundHandle implements BoundStorageHandle {
7878

7979
@Override
8080
public void recordLong(long value, Context context) {
81-
if (!recordingEnabled()) {
81+
if (!isEnabled()) {
8282
return;
8383
}
8484
handle.recordLong(value, attributes, context);

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/DefaultSynchronousMetricStorage.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ public void recordDouble(double value, Attributes attributes, Context context) {
101101
doRecordDouble(value, attributes, context);
102102
}
103103

104-
/** Returns whether recording is currently enabled. Used by bound record paths. */
105-
final boolean recordingEnabled() {
106-
return enabled;
107-
}
108-
109104
/**
110105
* Returns true if a double {@code value} should be recorded. Returns false (dropping the
111106
* measurement) when recording is disabled, or when {@code value} is NaN, logging in the latter

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/DeltaSynchronousMetricStorage.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -232,29 +232,20 @@ public MetricData collect(
232232
// Seed the new holder with the bound handles, so that (a) the bound wrappers survive the swap
233233
// (their bound instruments hold direct references), (b) a series recorded both bound and
234234
// unbound continues to share one wrapper, and (c) bound series are collected every interval.
235-
ConcurrentHashMap<Attributes, DeltaAggregatorHandle<T>> newHolderHandles;
236-
if (memoryMode == REUSABLE_DATA) {
237-
// Ping-pong between two maps. Copy bound wrappers into the next map so they appear every
238-
// interval rather than every other interval.
239-
holder.aggregatorHandles.forEach(
240-
(attributes, handle) -> {
241-
if (handle.bound) {
242-
previousCollectionAggregatorHandles.put(attributes, handle);
243-
}
244-
});
245-
newHolderHandles = previousCollectionAggregatorHandles;
246-
} else {
247-
// IMMUTABLE_DATA: unbound series start fresh each interval (the old map is abandoned), so
248-
// seed
249-
// the new holder with only the bound wrappers.
250-
newHolderHandles = new ConcurrentHashMap<>();
251-
holder.aggregatorHandles.forEach(
252-
(attributes, handle) -> {
253-
if (handle.bound) {
254-
newHolderHandles.put(attributes, handle);
255-
}
256-
});
257-
}
235+
// In REUSABLE_DATA we ping-pong between two maps, so the bound wrappers are copied into the
236+
// next
237+
// map; in IMMUTABLE_DATA the old map is abandoned and the new map starts with only the bound
238+
// wrappers.
239+
ConcurrentHashMap<Attributes, DeltaAggregatorHandle<T>> newHolderHandles =
240+
(memoryMode == REUSABLE_DATA)
241+
? previousCollectionAggregatorHandles
242+
: new ConcurrentHashMap<>();
243+
holder.aggregatorHandles.forEach(
244+
(attributes, handle) -> {
245+
if (handle.bound) {
246+
newHolderHandles.put(attributes, handle);
247+
}
248+
});
258249
this.aggregatorHolder = new AggregatorHolder<>(newHolderHandles);
259250

260251
ConcurrentHashMap<Attributes, DeltaAggregatorHandle<T>> aggregatorHandles =
@@ -403,7 +394,7 @@ private final class DeltaBoundHandle implements BoundStorageHandle {
403394

404395
@Override
405396
public void recordLong(long value, Context context) {
406-
if (!recordingEnabled()) {
397+
if (!isEnabled()) {
407398
return;
408399
}
409400
wrapper.recordLong(value, attributes, context);

0 commit comments

Comments
 (0)