public static GroupName valueOf(SimpleGroupPath path) { return valueOf(path, emptyMap()); }
public static GroupName valueOf(SimpleGroupPath path) { return valueOf(path, emptyMap()); }
public static GroupName valueOf(SimpleGroupPath path, Stream<Map.Entry<String, MetricValue>> tags) { return valueOf(path, Tags.valueOf(tags)); }
public static GroupName valueOf(SimpleGroupPath path, Map<String, MetricValue> tags) { return valueOf(path, Tags.valueOf(tags)); }
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
public static GroupName valueOf(SimpleGroupPath path, Map<String, MetricValue> tags) { return valueOf(path, Tags.valueOf(tags)); }
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
public static GroupName valueOf(SimpleGroupPath path, Stream<Map.Entry<String, MetricValue>> tags) { return valueOf(path, Tags.valueOf(tags)); }
private static GroupName calculate_new_name_(GroupName oldname, Map<String, MetricValue> tagged_values) { return GroupName.valueOf(oldname.getPath(), Stream.concat( oldname.getTags().stream().filter((Map.Entry<String, MetricValue> entry) -> !tagged_values.keySet().contains(entry.getKey())), tagged_values.entrySet().stream())); }
private static void addMetricMappingToCtx(Context<MutableTimeSeriesCollectionPair> ctx, SimpleGroupPath groupPath, MetricName metric, TagData tagData, Map.Entry<Tags, MetricValue> resolvedMetric) { final GroupName group; if (tagData.isEmpty()) { group = GroupName.valueOf(groupPath, resolvedMetric.getKey()); } else { final Map<String, MetricValue> tagMap = new HashMap<>(); tagMap.putAll(resolvedMetric.getKey().asMap()); tagData.getExtraTagsForTags(resolvedMetric.getKey()) .forEach((tagValue) -> tagMap.put(tagValue.getKey(), tagValue.getValue())); group = GroupName.valueOf(groupPath, tagMap); } final MetricValue metricValue = resolvedMetric.getValue(); ctx.getTSData().getCurrentCollection() .addMetric(group, metric, metricValue); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull List<String> prefixPath, @NonNull Map<String, MetricValue> extraTags) { final Stream<String> suffixPath = data.entrySet().stream() .filter(entry -> entry.getKey().getLeft().isPresent()) // Only retain int keys. .sorted(Comparator.comparing(entry -> entry.getKey().getLeft().get())) // Sort by int key. .map(Map.Entry::getValue) .map(value -> value.mapCombine(b -> b.toString(), i -> i.toString(), Function.identity())); final SimpleGroupPath path = SimpleGroupPath.valueOf(Stream.concat(prefixPath.stream(), suffixPath).collect(Collectors.toList())); final Map<String, MetricValue> tags = data.entrySet().stream() .filter(entry -> entry.getKey().getRight().isPresent()) // Only retain string keys. .collect(Collectors.toMap(entry -> entry.getKey().getRight().get(), entry -> entry.getValue().mapCombine(MetricValue::fromBoolean, MetricValue::fromIntValue, MetricValue::fromStrValue))); tags.putAll(extraTags); return GroupName.valueOf(path, tags); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull List<String> prefixPath, @NonNull Map<String, MetricValue> extraTags) { final Stream<String> suffixPath = data.entrySet().stream() .filter(entry -> entry.getKey().getLeft().isPresent()) // Only retain int keys. .sorted(Comparator.comparing(entry -> entry.getKey().getLeft().get())) // Sort by int key. .map(Map.Entry::getValue) .map(value -> value.mapCombine(b -> b.toString(), i -> i.toString(), Function.identity())); final SimpleGroupPath path = SimpleGroupPath.valueOf(Stream.concat(prefixPath.stream(), suffixPath).collect(Collectors.toList())); final Map<String, MetricValue> tags = data.entrySet().stream() .filter(entry -> entry.getKey().getRight().isPresent()) // Only retain string keys. .collect(Collectors.toMap(entry -> entry.getKey().getRight().get(), entry -> entry.getValue().mapCombine(MetricValue::fromBoolean, MetricValue::fromIntValue, MetricValue::fromStrValue))); tags.putAll(extraTags); return GroupName.valueOf(path, tags); }
public Stream<Alert> create_alert_(Context ctx) { final TimeSeriesCollectionPair ts_data = ctx.getTSData(); final Map<String, Any2<TimeSeriesMetricDeltaSet, List<TimeSeriesMetricDeltaSet>>> attr_map = calculate_attributes_(ctx); return alert_defn_.getName().apply(ctx) .map(path -> SimpleGroupPath.valueOf(path.getPath())) .map((name) -> { return alert_defn_.getPredicate().apply(ctx) .streamAsMap() .map((tag_val) -> SimpleMapEntry.create(tag_val.getKey(), tag_val.getValue().asBool())) .map((tag_bool) -> { final GroupName alert_name = GroupName.valueOf(name, tag_bool.getKey()); final Optional<Boolean> triggering = tag_bool.getValue(); Map<String, Any2<MetricValue, List<MetricValue>>> attrs = lookup_attributes_(alert_name.getTags(), attr_map); return new Alert(ts_data.getCurrentCollection().getTimestamp(), alert_name, alert_defn_::configString, triggering, alert_defn_.getFireDuration(), alert_defn_.getMessage(), attrs); }); }) .orElseGet(Stream::empty); }