com.jamonapi.utils.Misc Java Examples

The following examples show how to use com.jamonapi.utils.Misc. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JamonPerformanceMonitorInterceptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Count the thrown exception and put the stack trace in the details portion of the key.
 * This will allow the stack trace to be viewed in the JAMon web application.
 */
protected void trackException(MonKey key, Throwable ex) {
	String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex);
	key.setDetails(stackTrace);

	// Specific exception counter. Example: java.lang.RuntimeException
	MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1);

	// General exception counter which is a total for all exceptions thrown
	MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1);
}
 
Example #2
Source File: JamonPerformanceMonitorInterceptor.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Count the thrown exception and put the stack trace in the details portion of the key.
 * This will allow the stack trace to be viewed in the JAMon web application.
 */
protected void trackException(MonKey key, Throwable ex) {
	String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex);
	key.setDetails(stackTrace);

	// Specific exception counter. Example: java.lang.RuntimeException
	MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1);

	// General exception counter which is a total for all exceptions thrown
	MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1);
}
 
Example #3
Source File: JamonPerformanceMonitorInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Count the thrown exception and put the stack trace in the details portion of the key.
 * This will allow the stack trace to be viewed in the JAMon web application.
 */
protected void trackException(MonKey key, Throwable ex) {
	String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex);
	key.setDetails(stackTrace);

	// Specific exception counter. Example: java.lang.RuntimeException
	MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1);

	// General exception counter which is a total for all exceptions thrown
	MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1);
}
 
Example #4
Source File: JamonPerformanceMonitorInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Count the thrown exception and put the stack trace in the details portion of the key.
 * This will allow the stack trace to be viewed in the JAMon web application.
 */
protected void trackException(MonKey key, Throwable ex) {
	String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex);
	key.setDetails(stackTrace);

	// Specific exception counter. Example: java.lang.RuntimeException
	MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1);

	// General exception counter which is a total for all exceptions thrown
	MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1);
}
 
Example #5
Source File: CorePlugin.java    From restcommander with Apache License 2.0 4 votes vote down vote up
@Override
public JsonObject getJsonStatus() {
    JsonObject status = new JsonObject();

    {
        JsonObject java = new JsonObject();
        java.addProperty("version", System.getProperty("java.version"));
        status.add("java", java);
    }

    {
        JsonObject memory = new JsonObject();
        memory.addProperty("max", Runtime.getRuntime().maxMemory());
        memory.addProperty("free", Runtime.getRuntime().freeMemory());
        memory.addProperty("total", Runtime.getRuntime().totalMemory());
        status.add("memory", memory);
    }

    {
        JsonObject application = new JsonObject();
        application.addProperty("uptime", Play.started ? System.currentTimeMillis() - Play.startedAt : -1);
        application.addProperty("path", Play.applicationPath.getAbsolutePath());
        status.add("application", application);
    }

    {
        JsonObject pool = new JsonObject();
        pool.addProperty("size", Invoker.executor.getPoolSize());
        pool.addProperty("active", Invoker.executor.getActiveCount());
        pool.addProperty("scheduled", Invoker.executor.getTaskCount());
        pool.addProperty("queue", Invoker.executor.getQueue().size());
        status.add("pool", pool);
    }

    {
        JsonArray monitors = new JsonArray();
        try {
            Object[][] data = Misc.sort(MonitorFactory.getRootMonitor().getBasicData(), 3, "desc");
            for (Object[] row : data) {
                if (((Double) row[1]) > 0) {
                    JsonObject o = new JsonObject();
                    o.addProperty("name", row[0].toString());
                    o.addProperty("hits", (Double) row[1]);
                    o.addProperty("avg", (Double) row[2]);
                    o.addProperty("min", (Double) row[6]);
                    o.addProperty("max", (Double) row[7]);
                    monitors.add(o);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        status.add("monitors", monitors);
    }

    return status;
}