Align behaviour of in-memory and redis mult repos
The in-memory version has to force the incoming metric keys to start with the group name. Redis doesn't have that restriction but normally we expect both to be used in such a way that the metric keys already match the prefix. In that case the two repositories behave the same now in terms of set and get.
This commit is contained in:
@@ -144,12 +144,8 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
}
|
||||
|
||||
private Metric<?> deserialize(String group, String redisKey, String v, Double value) {
|
||||
String prefix = group;
|
||||
if (!group.endsWith(".")) {
|
||||
prefix = group + ".";
|
||||
}
|
||||
Date timestamp = new Date(Long.valueOf(v));
|
||||
return new Metric<Double>(prefix + nameFor(redisKey), value, timestamp);
|
||||
return new Metric<Double>(nameFor(redisKey), value, timestamp);
|
||||
}
|
||||
|
||||
private String serialize(Metric<?> entity) {
|
||||
|
||||
@@ -82,9 +82,9 @@ public class InMemoryPrefixMetricRepositoryTests {
|
||||
|
||||
@Test
|
||||
public void incrementGroup() {
|
||||
this.repository.increment("foo", new Delta<Number>("bar", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("bar", 2));
|
||||
this.repository.increment("foo", new Delta<Number>("spam", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Metric<?> metric : this.repository.findAll("foo")) {
|
||||
names.add(metric.getName());
|
||||
|
||||
@@ -116,9 +116,9 @@ public class RedisMultiMetricRepositoryTests {
|
||||
|
||||
@Test
|
||||
public void increment() {
|
||||
this.repository.increment("foo", new Delta<Number>("bar", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("bar", 2));
|
||||
this.repository.increment("foo", new Delta<Number>("spam", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
|
||||
this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
|
||||
Metric<?> bar = null;
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Metric<?> metric : this.repository.findAll("foo")) {
|
||||
|
||||
Reference in New Issue
Block a user