use of com.codahale.metrics.MetricRegistry in project indy by Commonjava.
the class ReporterIntializer method initZabbixReporterForHealthCheckMetric.
private void initZabbixReporterForHealthCheckMetric(MetricRegistry metrics, IndyMetricsConfig config) {
IndyZabbixReporter reporter = initZabbixReporter(metrics, config).filter((name, metric) -> {
if (!name.contains(FILTER_SIMPLE) && name.contains(FILTER_HEALTHCHECK)) {
return true;
}
return false;
}).build(initZabbixSender());
reporter.start(config.getZabbixHealthcheckPeriod(), TimeUnit.SECONDS);
}
use of com.codahale.metrics.MetricRegistry in project indy by Commonjava.
the class ReporterIntializer method initGraphiteReporterForSimpleMetric.
private void initGraphiteReporterForSimpleMetric(MetricRegistry metrics, IndyMetricsConfig config) {
final Graphite graphite = new Graphite(new InetSocketAddress(config.getGrphiterHostName(), config.getGrphiterPort()));
final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics).prefixedWith(config.getGrphiterPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter((name, metric) -> {
if (name.contains(FILTER_SIMPLE)) {
return true;
}
return false;
}).build(graphite);
reporter.start(config.getGrphiterSimplePriod(), TimeUnit.SECONDS);
}
use of com.codahale.metrics.MetricRegistry in project opennms by OpenNMS.
the class EventExpanderTest method testAfterPropertiesSetWithNoEventConfDao.
@Test
public void testAfterPropertiesSetWithNoEventConfDao() {
m_mocks.replayAll();
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalStateException("property eventConfDao must be set"));
EventExpander expander = new EventExpander(new MetricRegistry());
try {
expander.afterPropertiesSet();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of com.codahale.metrics.MetricRegistry in project opennms by OpenNMS.
the class StressCommand method execute.
@Override
public Object execute() throws Exception {
// Create the client
final RpcClient<EchoRequest, EchoResponse> client = rpcClientFactory.getClient(EchoRpcModule.INSTANCE);
// Create metrics to capture the results
final MetricRegistry metrics = new MetricRegistry();
final Histogram responseTimes = metrics.histogram("response-times");
final Counter successes = metrics.counter("successes");
final Counter failures = metrics.counter("failures");
// Build and issue the requests
System.out.printf("Executing %d requests.\n", count);
final String message = Strings.repeat("*", messageSize);
final CountDownLatch doneSignal = new CountDownLatch(count);
long beforeExec = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
client.execute(buildRequest(message)).whenComplete((r, e) -> {
if (e != null) {
failures.inc();
} else {
responseTimes.update(System.currentTimeMillis() - r.getId());
successes.inc();
}
doneSignal.countDown();
});
}
long afterExec = System.currentTimeMillis();
// Wait for the responses...
System.out.printf("Waiting for responses.\n");
while (true) {
try {
if (doneSignal.await(1, TimeUnit.SECONDS)) {
// Done!
System.out.printf("\nDone!\n");
break;
}
} catch (InterruptedException e) {
System.out.println("\nInterrupted!");
break;
}
System.out.print(".");
System.out.flush();
}
long afterResponse = System.currentTimeMillis();
System.out.println();
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.MILLISECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.report();
reporter.close();
System.out.printf("Total miliseconds elapsed: %d\n", afterResponse - beforeExec);
System.out.printf("Miliseconds spent generating requests: %d\n", afterExec - beforeExec);
System.out.printf("Miliseconds spent waiting for responses: %d\n", afterResponse - afterExec);
return null;
}
use of com.codahale.metrics.MetricRegistry in project opennms by OpenNMS.
the class Nms4335IT method doMessageTest.
/**
* Send a raw syslog message and expect a given event as a result
*
* @param testPDU The raw syslog message as it would appear on the wire (just the UDP payload)
* @param expectedHost The host from which the event should be resolved as originating
* @param expectedUEI The expected UEI of the resulting event
* @param expectedLogMsg The expected contents of the logmsg for the resulting event
*
* @throws UnknownHostException
* @throws InterruptedException
* @throws ExecutionException
*/
private List<Event> doMessageTest(String testPDU, String expectedHost, String expectedUEI, String expectedLogMsg) throws UnknownHostException, InterruptedException, ExecutionException {
SyslogdTestUtils.startSyslogdGracefully(m_syslogd);
final EventBuilder expectedEventBldr = new EventBuilder(expectedUEI, "syslogd");
expectedEventBldr.setInterface(addr(expectedHost));
expectedEventBldr.setLogDest("logndisplay");
expectedEventBldr.setLogMessage(expectedLogMsg);
m_eventIpcManager.getEventAnticipator().anticipateEvent(expectedEventBldr.getEvent());
final SyslogSinkConsumer syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
syslogSinkConsumer.setSyslogdConfig(m_config);
syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
final SyslogSinkModule syslogSinkModule = syslogSinkConsumer.getModule();
final SyslogClient sc = new SyslogClient(null, 10, SyslogClient.LOG_DAEMON, addr("127.0.0.1"));
final DatagramPacket pkt = sc.getPacket(SyslogClient.LOG_DEBUG, testPDU);
final SyslogMessageLogDTO messageLog = syslogSinkModule.toMessageLog(new SyslogConnection(pkt, false));
syslogSinkConsumer.handleMessage(messageLog);
m_eventIpcManager.getEventAnticipator().verifyAnticipated(5000, 0, 0, 0, 0);
final Event receivedEvent = m_eventIpcManager.getEventAnticipator().getAnticipatedEventsReceived().get(0);
assertEquals("Log messages do not match", expectedLogMsg, receivedEvent.getLogmsg().getContent());
return m_eventIpcManager.getEventAnticipator().getAnticipatedEventsReceived();
}
Aggregations