Skip to content

Commit e1d3a8b

Browse files
authored
Dimensions on Periodic Metrics (#174)
* Extract configured dimensions from the data stream and bucket periodic instrument by them. * Added a test and fixed sample counting.
1 parent 02ed1e9 commit e1d3a8b

File tree

4 files changed

+276
-94
lines changed

4 files changed

+276
-94
lines changed

src/main/java/com/arpnetworking/tsdcore/model/DefaultKey.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import com.arpnetworking.logback.annotations.Loggable;
1919
import com.google.common.base.MoreObjects;
2020
import com.google.common.collect.ImmutableMap;
21+
import com.google.common.collect.ImmutableSet;
2122

23+
import java.util.Map;
2224
import java.util.Objects;
2325

2426
/**
@@ -49,6 +51,17 @@ public String getHost() {
4951
return _dimensions.get(HOST_DIMENSION_KEY);
5052
}
5153

54+
@Override
55+
public Key filter(final ImmutableSet<String> keys) {
56+
return new DefaultKey(
57+
_dimensions.entrySet()
58+
.stream()
59+
.filter(e -> keys.contains(e.getKey()))
60+
.collect(ImmutableMap.toImmutableMap(
61+
Map.Entry::getKey,
62+
Map.Entry::getValue)));
63+
}
64+
5265
@Override
5366
public boolean equals(final Object other) {
5467
if (this == other) {

src/main/java/com/arpnetworking/tsdcore/model/Key.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.arpnetworking.tsdcore.model;
1717

1818
import com.google.common.collect.ImmutableMap;
19+
import com.google.common.collect.ImmutableSet;
1920

2021
/**
2122
* Interface for aggregation context (e.g. slice of hyper-cube).
@@ -52,6 +53,15 @@ public interface Key {
5253
*/
5354
String getHost();
5455

56+
/**
57+
* Create a {@link Key} from this key that contains a subset of the
58+
* parameters by parameter key.
59+
*
60+
* @param keys the parameter keys to retain in the returned {@link Key}
61+
* @return instance of {@link Key} with only specified parameter keys and values
62+
*/
63+
Key filter(ImmutableSet<String> keys);
64+
5565
/**
5666
* The dimension key for the cluster attribute.
5767
*/

0 commit comments

Comments
 (0)