Skip to content

Commit ee0d438

Browse files
authored
Change the usage of MMSC aggregations to always be deltas. (#1368)
1 parent f28396b commit ee0d438

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleValueRecorderSdk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private DoubleValueRecorderSdk(
3535
meterProviderSharedState,
3636
meterSharedState,
3737
new ActiveBatcher(
38-
Batchers.getCumulativeAllLabels(
38+
Batchers.getDeltaAllLabels(
3939
descriptor,
4040
meterProviderSharedState,
4141
meterSharedState,

sdk/src/main/java/io/opentelemetry/sdk/metrics/LongValueRecorderSdk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private LongValueRecorderSdk(
3535
meterProviderSharedState,
3636
meterSharedState,
3737
new ActiveBatcher(
38-
Batchers.getCumulativeAllLabels(
38+
Batchers.getDeltaAllLabels(
3939
descriptor,
4040
meterProviderSharedState,
4141
meterSharedState,

sdk/src/test/java/io/opentelemetry/sdk/metrics/DoubleValueRecorderSdkTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public void collectMetrics_WithMultipleCollects() {
185185
323.3d,
186186
valueAtPercentiles(-121.5d, 321.5d)));
187187

188-
// Repeat to prove we keep previous values.
188+
// Repeat to prove we don't keep previous values.
189189
testClock.advanceNanos(SECOND_NANOS);
190190
boundMeasure.record(222d);
191191
doubleMeasure.record(17d, Labels.empty());
@@ -197,19 +197,19 @@ public void collectMetrics_WithMultipleCollects() {
197197
assertThat(metricData.getPoints())
198198
.containsExactly(
199199
SummaryPoint.create(
200-
startTime,
200+
startTime + SECOND_NANOS,
201201
secondCollect,
202202
Labels.empty(),
203-
3,
204-
16.0d,
205-
valueAtPercentiles(-13.1d, 17d)),
203+
1,
204+
17.0d,
205+
valueAtPercentiles(17d, 17d)),
206206
SummaryPoint.create(
207-
startTime,
207+
startTime + SECOND_NANOS,
208208
secondCollect,
209209
Labels.of("K", "V"),
210-
4,
211-
545.3d,
212-
valueAtPercentiles(-121.5, 321.5d)));
210+
1,
211+
222.0d,
212+
valueAtPercentiles(222.0, 222.0d)));
213213
} finally {
214214
boundMeasure.unbind();
215215
}

sdk/src/test/java/io/opentelemetry/sdk/metrics/LongValueRecorderSdkTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void collectMetrics_WithMultipleCollects() {
180180
323,
181181
valueAtPercentiles(-121, 321)));
182182

183-
// Repeat to prove we keep previous values.
183+
// Repeat to prove we don't keep previous values.
184184
testClock.advanceNanos(SECOND_NANOS);
185185
boundMeasure.record(222);
186186
longMeasure.record(17, Labels.empty());
@@ -193,14 +193,19 @@ public void collectMetrics_WithMultipleCollects() {
193193
assertThat(metricData.getPoints())
194194
.containsExactly(
195195
SummaryPoint.create(
196-
startTime, secondCollect, Labels.empty(), 3, 15, valueAtPercentiles(-14, 17)),
196+
startTime + SECOND_NANOS,
197+
secondCollect,
198+
Labels.empty(),
199+
1,
200+
17,
201+
valueAtPercentiles(17, 17)),
197202
SummaryPoint.create(
198-
startTime,
203+
startTime + SECOND_NANOS,
199204
secondCollect,
200205
Labels.of("K", "V"),
201-
4,
202-
545,
203-
valueAtPercentiles(-121, 321)));
206+
1,
207+
222,
208+
valueAtPercentiles(222, 222)));
204209
} finally {
205210
boundMeasure.unbind();
206211
}

0 commit comments

Comments
 (0)