Skip to content

Commit 1029615

Browse files
Defer to rescaling if values don't fit in the bucket
- Rescaling is not frequent behaviour (for cumulative scale should normalize after initial few recording, for delta it could increase/decrease but would be mostly stable) hence we would re-try the record behaviour if the index won't fit in the value.
1 parent 3383e5c commit 1029615

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/internal/CircularCountHolder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ else if (index < startIndex) {
8181
startIndex = index;
8282
}
8383

84-
counts.addAndGet(getRelativeIndex(index), incrementBy);
85-
return true;
84+
final int relativeIndex = getRelativeIndex(index);
85+
if (relativeIndex >= 0 && relativeIndex < length) {
86+
counts.addAndGet(relativeIndex, incrementBy);
87+
return true;
88+
}
89+
return false;
8690
}
8791

8892
private int getRelativeIndex(int index) {

0 commit comments

Comments
 (0)