Skip to content

Commit 6e96eda

Browse files
committed
set epoch info once
1 parent 4fe5834 commit 6e96eda

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public final class SdkObservableMeasurement
3636
// These fields are set before invoking callbacks. They allow measurements to be recorded to the
3737
// storages for correct reader, and with the correct time.
3838
@Nullable private volatile RegisteredReader activeReader;
39-
private volatile long startEpochNanos;
40-
private volatile long epochNanos;
4139

4240
private SdkObservableMeasurement(
4341
InstrumentationScopeInfo instrumentationScopeInfo,
@@ -75,8 +73,11 @@ public InstrumentationScopeInfo getInstrumentationScopeInfo() {
7573
public void setActiveReader(
7674
RegisteredReader registeredReader, long startEpochNanos, long epochNanos) {
7775
this.activeReader = registeredReader;
78-
this.startEpochNanos = startEpochNanos;
79-
this.epochNanos = epochNanos;
76+
for (AsynchronousMetricStorage<?, ?> storage : storages) {
77+
if (storage.getRegisteredReader().equals(activeReader)) {
78+
storage.setEpochInformation(startEpochNanos, epochNanos);
79+
}
80+
}
8081
}
8182

8283
/**
@@ -109,7 +110,6 @@ public void record(long value, Attributes attributes) {
109110

110111
for (AsynchronousMetricStorage<?, ?> storage : storages) {
111112
if (storage.getRegisteredReader().equals(activeReader)) {
112-
storage.setEpochInformation(startEpochNanos, epochNanos);
113113
storage.record(attributes, value);
114114
}
115115
}
@@ -141,7 +141,6 @@ public void record(double value, Attributes attributes) {
141141

142142
for (AsynchronousMetricStorage<?, ?> storage : storages) {
143143
if (storage.getRegisteredReader().equals(activeReader)) {
144-
storage.setEpochInformation(startEpochNanos, epochNanos);
145144
storage.record(attributes, value);
146145
}
147146
}

0 commit comments

Comments
 (0)