Skip to content

Commit 9818cd5

Browse files
authored
fix: drop negative counter inc (#366)
1 parent b35b621 commit 9818cd5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/main/java/io/getunleash/impactmetrics/CounterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void inc(long value) {
2828

2929
@Override
3030
public void inc(long value, Map<String, String> labels) {
31-
if (value == 0) {
31+
if (value <= 0) {
3232
return;
3333
}
3434
String key = getLabelKey(labels);

src/test/java/io/getunleash/impactmetrics/MetricTypeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void should_increment_with_custom_value_and_labels() {
3333
Counter counter = registry.counter(new MetricOptions("labeled_counter", "with labels"));
3434

3535
counter.inc(3, Map.of("foo", "bar"));
36+
counter.inc(-1, Map.of("foo", "bar"));
3637
counter.inc(2, Map.of("foo", "bar"));
3738

3839
List<CollectedMetric> metrics = registry.collect();

0 commit comments

Comments
 (0)