no.finn.unleash.metric.MetricsBucket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unleash-client-java Show documentation
Show all versions of unleash-client-java Show documentation
A client library for Unleash
package no.finn.unleash.metric;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.HashMap;
import java.util.Map;
class MetricsBucket {
private final Map toggles;
private final LocalDateTime start;
private LocalDateTime stop;
MetricsBucket() {
this.start = LocalDateTime.now(ZoneId.of("UTC"));
this.toggles = new HashMap<>();
}
void registerCount(String toggleName, boolean active) {
if(toggles.containsKey(toggleName)) {
toggles.get(toggleName).register(active);
} else {
ToggleCount counter = new ToggleCount();
counter.register(active);
toggles.put(toggleName, counter);
}
}
void end() {
this.stop = LocalDateTime.now(ZoneId.of("UTC"));
}
public Map getToggles() {
return toggles;
}
public LocalDateTime getStart() {
return start;
}
public LocalDateTime getStop() {
return stop;
}
}