com.wavefront.ingester.OpenTSDBDecoder Maven / Gradle / Ivy
The newest version!
package com.wavefront.ingester;
import com.google.common.base.Preconditions;
import java.util.List;
import com.google.common.collect.ImmutableList;
import wavefront.report.ReportPoint;
/**
* OpenTSDB decoder that takes in a point of the type:
*
* PUT [metric] [timestamp] [value] [annotations]
*
* @author Clement Pang ([email protected]).
*/
@Deprecated
public class OpenTSDBDecoder implements Decoder {
private static final AbstractIngesterFormatter FORMAT =
ReportPointIngesterFormatter.newBuilder().
caseInsensitiveLiterals(ImmutableList.of("put")).
text(ReportPoint::setMetric).
timestamp(ReportPoint::setTimestamp).
value(ReportPoint::setValue).
annotationMap(ReportPoint::setAnnotations).
build();
private final String hostName;
private List customSourceTags;
public OpenTSDBDecoder(List customSourceTags) {
this("unknown", customSourceTags);
}
public OpenTSDBDecoder(String hostName, List customSourceTags) {
Preconditions.checkNotNull(hostName);
Preconditions.checkNotNull(customSourceTags);
this.hostName = hostName;
this.customSourceTags = customSourceTags;
}
@Override
public void decodeReportPoints(String msg, List out, String customerId) {
ReportPoint point = FORMAT.drive(msg, () -> hostName, customerId, customSourceTags, null, null, null, null, null, null, null);
if (out != null) {
out.add(point);
}
}
@Override
public void decodeReportPoints(String msg, List out, String customerId, IngesterContext ingesterContext) {
ReportPoint point = FORMAT.drive(msg, () -> hostName, customerId, customSourceTags, null, null, null, null,null, null, ingesterContext);
if (out != null) {
out.add(point);
}
}
@Override
public void decodeReportPoints(String msg, List out) {
decodeReportPoints(msg, out, "dummy");
}
}