Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Treat gauge.update() parameter as new value, not delta #463

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Gauge createGauge(final String name, final Map<String, String> tags) {
return new Gauge() {
@Override
public void update(long amount) {
value.addAndGet(amount);
value.getAndSet(amount);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ public void metricNameIsUsedForGauge() {
}

@Test
public void gaugeValueIsIncreased() {
public void gaugeValueIsUpdated() {
Map<String, String> tags = Collections.singletonMap("foo", "bar");

InMemoryMetricsFactory inMemoryMetricsFactory = new InMemoryMetricsFactory();
Gauge gauge = inMemoryMetricsFactory.createGauge("thegauge", tags);
assertEquals(0, inMemoryMetricsFactory.getGauge("thegauge", tags));

gauge.update(1);

assertEquals(1, inMemoryMetricsFactory.getGauge("thegauge", tags));

gauge.update(2);
assertEquals(2, inMemoryMetricsFactory.getGauge("thegauge", tags));
}

@Test
Expand Down