public void addTag(String name, String val) { /* * Remove existing tags that will be updated */ Monitor.tags.removeIf(p -> { return p.getKey().equals(name); }); Monitor.tags.add(new Tag(name, val)); }
public Map<String, String> getTagsMap() { HashMap<String, String> map = new HashMap<String, String>(); Monitor.tags.forEach(t -> { map.put(t.getKey(), t.getValue()); }); return map; }
public Map<String, String> getTagsMap() { HashMap<String, String> map = new HashMap<String, String>(); Monitor.tags.forEach(t -> { map.put(t.getKey(), t.getValue()); }); return map; }
public void addTag(String name, String val) { /* * Remove existing tags that will be updated */ Monitor.tags.removeIf(p -> { return p.getKey().equals(name); }); Monitor.tags.add(new Tag(name, val)); }
public void addTagsMap(Map<String, String> tags) { /* * Remove existing tags that will be updated */ Monitor.tags.removeIf(p -> { return tags.containsKey(p.getKey()); }); /* * Add new / update tags */ tags.forEach((k, v) -> { Monitor.tags.add(new Tag(k, v)); }); }
public void addTagsMap(Map<String, String> tags) { /* * Remove existing tags that will be updated */ Monitor.tags.removeIf(p -> { return tags.containsKey(p.getKey()); }); /* * Add new / update tags */ tags.forEach((k, v) -> { Monitor.tags.add(new Tag(k, v)); }); }
private Collection<Dimension> tagsToDimensions(final Set<Tag> tags) { return tags.stream().map(e -> tagToDim(e.getKey(), e.getValue())).collect(Collectors.toList()); }
private Collection<Dimension> tagsToDimensions(final Set<Tag> tags) { return tags.stream().map(e -> tagToDim(e.getKey(), e.getValue())).collect(Collectors.toList()); }
@Override public void write(ArrayList<Stat> stats, long invokeTimeMs, Set<Tag> tags) { Set<Tag> allTags = new HashSet<Tag>(); /* * DataDog only tracks to second precision */ long ts = invokeTimeMs / 1000; for (Stat stat : stats) { allTags.addAll(tags); allTags.addAll(stat.getTags()); String tagsString = allTags.stream().map(e -> formatEntry(e.getKey(), e.getValue())) .collect(Collectors.joining(",")); /* * MONITORING|unix_epoch_timestamp|value|metric_type|my.metric.name|#tag1:value,tag2 */ String[] logParts = {"MONITORING", "" + ts, "" + stat.getValue(), stat.getType().name(), prefix + "." + stat.getName(), "#" + tagsString}; allTags.clear(); System.out.println(String.join("|", logParts)); } }
@Override public void write(ArrayList<Stat> stats, long invokeTimeMs, Set<Tag> tags) { Set<Tag> allTags = new HashSet<Tag>(); /* * DataDog only tracks to second precision */ long ts = invokeTimeMs / 1000; for (Stat stat : stats) { allTags.addAll(tags); allTags.addAll(stat.getTags()); String tagsString = allTags.stream().map(e -> formatEntry(e.getKey(), e.getValue())) .collect(Collectors.joining(",")); /* * MONITORING|unix_epoch_timestamp|value|metric_type|my.metric.name|#tag1:value,tag2 */ String[] logParts = {"MONITORING", "" + ts, "" + stat.getValue(), stat.getType().name(), prefix + "." + stat.getName(), "#" + tagsString}; allTags.clear(); System.out.println(String.join("|", logParts)); } }
@Override public void write(ArrayList<Stat> stats, long invokeTimeMs, Set<Tag> tags) { Set<Tag> allTags = new HashSet<Tag>(); for (Stat stat : stats) { allTags.addAll(tags); allTags.addAll(stat.getTags()); String tagsString = allTags.stream().map(e -> formatEntry(e.getKey(), e.getValue())) .collect(Collectors.joining(",")); String metric = String.format("%s %s %d", stat.getName(), tagsString, stat.getValue()); buffer.add(metric); allTags.clear(); } }