com.wavefront.ingester.GraphiteHostAnnotator Maven / Gradle / Ivy
package com.wavefront.ingester;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
/**
* Given a raw graphite line, look for any host tag, and add it if implicit. Does not perform full
* decoding, though.
*/
public class GraphiteHostAnnotator extends MessageToMessageDecoder {
private final String hostName;
private final List sourceTags = new ArrayList<>();
public GraphiteHostAnnotator(String hostName, final List customSourceTags) {
this.hostName = hostName;
this.sourceTags.add("source=");
this.sourceTags.add("host=");
this.sourceTags.addAll(customSourceTags.stream().map(customTag -> customTag + "=").collect(Collectors.toList()));
}
// Decode from a possibly host-annotated graphite string to a definitely host-annotated graphite string.
@Override
protected void decode(ChannelHandlerContext ctx, String msg, List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy