Search in sources :

Example 1 with Tag

use of com.nextdoor.bender.monitoring.Tag in project bender by Nextdoor.

the class DataDogReporter method write.

@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));
    }
}
Also used : HashSet(java.util.HashSet) Reporter(com.nextdoor.bender.monitoring.Reporter) List(java.util.List) Set(java.util.Set) Stat(com.nextdoor.bender.monitoring.Stat) Tag(com.nextdoor.bender.monitoring.Tag) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StatFilter(com.nextdoor.bender.monitoring.StatFilter) Stat(com.nextdoor.bender.monitoring.Stat) Tag(com.nextdoor.bender.monitoring.Tag) HashSet(java.util.HashSet)

Aggregations

Reporter (com.nextdoor.bender.monitoring.Reporter)1 Stat (com.nextdoor.bender.monitoring.Stat)1 StatFilter (com.nextdoor.bender.monitoring.StatFilter)1 Tag (com.nextdoor.bender.monitoring.Tag)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1