com.jamonapi.MonKey Java Examples

The following examples show how to use com.jamonapi.MonKey. 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 6 votes vote down vote up
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			writeToLog(logger, "JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
Example #2
Source File: JamonPerformanceMonitorInterceptor.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			writeToLog(logger, "JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
Example #3
Source File: JamonPerformanceMonitorInterceptor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			writeToLog(logger, "JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
Example #4
Source File: JamonPerformanceMonitorInterceptor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
Example #5
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 #6
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 #7
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 #8
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 #9
Source File: Jamon.java    From automon with Apache License 2.0 5 votes vote down vote up
@Override
protected void trackException(JoinPoint jp, Throwable throwable) {
    AutomonExpirable exceptionContext = populateExceptionContext(jp, throwable);
    // Multiple monitors are tracked for the exception such as one of the specific exception and one that represents
    // all exceptions.
    List<String> labels = getLabels(throwable);
    for (String label : labels) {
        MonKey key = new MonKeyImp(label, exceptionContext.getJamonDetails(), "Exception");
        MonitorFactory.add(key, 1);
    }
}