use of io.fabric8.insight.metrics.mvel.Renderer in project fabric8 by jboss-fuse.
the class Log4jLogQuery method toLogEvent.
protected LogEvent toLogEvent(LoggingEvent element) {
LogEvent answer = new LogEvent();
answer.setClassName(element.getFQNOfLoggerClass());
// TODO
// answer.setContainerName(element.get);
ThrowableInformation throwableInformation = element.getThrowableInformation();
if (throwableInformation != null) {
ThrowableFormatter renderer = new ThrowableFormatter();
String[] stack = renderer.doRender(throwableInformation.getThrowable());
if (stack == null) {
stack = element.getThrowableStrRep();
}
answer.setException(stack);
}
LocationInfo locationInformation = element.getLocationInformation();
if (locationInformation != null) {
answer.setFileName(locationInformation.getFileName());
answer.setClassName(locationInformation.getClassName());
answer.setMethodName(locationInformation.getMethodName());
answer.setLineNumber(locationInformation.getLineNumber());
}
Level level = element.getLevel();
if (level != null) {
answer.setLevel(level.toString());
}
// TODO
answer.setLogger(element.getLoggerName());
Category logger = element.getLogger();
Object message = element.getMessage();
if (message != null) {
// TODO marshal differently?
answer.setMessage(message.toString());
}
answer.setProperties(element.getProperties());
// TODO
answer.setSeq(element.getTimeStamp());
answer.setTimestamp(new Date(element.getTimeStamp()));
answer.setThread(element.getThreadName());
answer.setHost(getHostName());
return answer;
}
use of io.fabric8.insight.metrics.mvel.Renderer in project fabric8 by jboss-fuse.
the class MetricsTest method testDefault.
@Test
public void testDefault() throws Exception {
Query query = new Query("test", new HashSet<Request>(Arrays.asList(new MBeanAttrs("memory", "java.lang:type=Memory", Arrays.asList("HeapMemoryUsage", "NonHeapMemoryUsage")), new MBeanOpers("deadlocks", "java.lang:type=Threading", "dumpAllThreads", Arrays.<Object>asList(true, true), Arrays.<String>asList(boolean.class.getName(), boolean.class.getName())))), null, null, null, 0, 0);
System.gc();
QueryResult qrs = JmxUtils.execute(new Server("local"), query, ManagementFactory.getPlatformMBeanServer());
String output = new Renderer().render(qrs);
Map map = new ObjectMapper().readValue(output, Map.class);
assertEquals("local", map.get("host"));
assertNotNull(map.get("@timestamp"));
}
Aggregations