}
@Override
public void process(TelemetryInfo telemetryInfo)
{
ReconnectingSocket socket = reconnectingSocket.get();
if (socket == null || !socket.isConnected())
return;
String name = telemetryInfo.getName();
if (globalRedact != null) {
name = name.replace(globalRedact, "");
}
if (globalPrefix != null) {
name = (globalPrefix + ".") + name;
}
long createdAt = telemetryInfo.getCreatedAt() / 1000; // Graphite uses UNIX epoch
StringBuffer data = new StringBuffer(256);
for (String attrName : telemetryInfo.getAttributeNames()) {
// we never care about NAME or CREATED_AT
if (attrName.equals(TelemetryInfo.ATTR_NAME) || attrName.equals(TelemetryInfo.ATTR_CREATED_AT))
continue;
// allow a chance to filter out based on attrName too (FilteringTelemetryInfoProcessor
// can only filter on telemetryInfo.name)
String statisticName = name + "." + attrName;
if (!telemetryNameFilter.process(statisticName))
continue;
Object attrValue = telemetryInfo.get(attrName);
if (attrValue instanceof Double || attrValue instanceof Float ||
attrValue instanceof Integer || attrValue instanceof Long) {
data.setLength(0);
data.append(statisticName);
data.append(" ").append(attrValue.toString());
data.append(" ").append(createdAt).append("\n");
String dataStr = data.toString();
socket.write(dataStr);
log.debug(dataStr);
}
}
}