use of org.collectd.api.ValueList in project metrics by dropwizard.
the class CollectdReporterTest method sanitizesMetricName.
@Test
public void sanitizesMetricName() throws Exception {
Counter counter = registry.counter("dash-illegal.slash/illegal");
counter.inc();
reporter.report();
ValueList values = receiver.next();
assertThat(values.getPlugin()).isEqualTo("dash_illegal.slash_illegal");
}
use of org.collectd.api.ValueList in project metrics by dropwizard.
the class CollectdReporterTest method reportsBooleanGauges.
@Test
public void reportsBooleanGauges() throws Exception {
reporter.report(map("gauge", (Gauge) () -> true), map(), map(), map(), map());
ValueList data = receiver.next();
assertThat(data.getValues()).containsExactly(1d);
reporter.report(map("gauge", (Gauge) () -> false), map(), map(), map(), map());
data = receiver.next();
assertThat(data.getValues()).containsExactly(0d);
}
use of org.collectd.api.ValueList in project metrics by dropwizard.
the class Receiver method before.
@Override
protected void before() throws Throwable {
receiver = new UdpReceiver(new Dispatcher() {
@Override
public void dispatch(ValueList values) {
queue.offer(new ValueList(values));
}
@Override
public void dispatch(Notification notification) {
throw new UnsupportedOperationException();
}
});
receiver.setPort(port);
new Thread(() -> {
try {
receiver.listen();
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
use of org.collectd.api.ValueList in project jcollectd by collectd.
the class MBeanCollector method dispatch.
private void dispatch(MBeanQuery query, String plugin, String typeInstance, ObjectName name, MBeanAttribute attr, Number val) {
if (attr.getDataType() == Network.DS_TYPE_GAUGE) {
val = new Double(val.doubleValue());
} else {
val = new Long(val.longValue());
}
String pluginInstance = query.getPluginInstance();
if (pluginInstance == null) {
pluginInstance = _sender.getInstanceName();
}
String beanName = query.getAlias();
ValueList vl = new ValueList();
vl.setInterval(getInterval());
vl.setPlugin(plugin);
if (beanName == null) {
beanName = getBeanName(null, name);
} else if (query.getName().isPattern()) {
String instName = getBeanName(query.getName(), name);
if (instName != null) {
beanName += " " + instName;
}
}
vl.setPluginInstance(pluginInstance + "-" + beanName);
vl.setType(attr.getTypeName());
vl.setTypeInstance(typeInstance);
vl.addValue(val);
_sender.dispatch(vl);
}
use of org.collectd.api.ValueList in project jcollectd by collectd.
the class PacketWriter method write.
public void write(PluginData data) throws IOException {
String type = data.getType();
writeString(Network.TYPE_HOST, data.getHost());
writeNumber(Network.TYPE_TIME, data.getTime() / 1000);
writeString(Network.TYPE_PLUGIN, data.getPlugin());
writeString(Network.TYPE_PLUGIN_INSTANCE, data.getPluginInstance());
writeString(Network.TYPE_TYPE, type);
writeString(Network.TYPE_TYPE_INSTANCE, data.getTypeInstance());
if (data instanceof ValueList) {
ValueList vl = (ValueList) data;
List<DataSource> ds = _types.getType(type);
List<Number> values = vl.getValues();
if ((ds != null) && (ds.size() != values.size())) {
String msg = type + " datasource mismatch, expecting " + ds.size() + ", given " + values.size();
throw new IOException(msg);
}
writeNumber(Network.TYPE_INTERVAL, vl.getInterval());
writeValues(ds, values);
} else {
// XXX Notification
}
}
Aggregations