Counter implements Cloneable, Serializable { public void addRequestForSystemError(String requestName, long duration, int cpuTime, int allocatedKBytes, String stackTrace) { assert requestName != null; assert duration >= -1; assert cpuTime >= -1; assert errorCounter; assert contextThreadLocal.get() == null; final String aggregateRequestName = getAggregateRequestName(requestName); final CounterRequest request = getCounterRequestInternal(aggregateRequestName); synchronized (request) { request.addHit(duration, cpuTime, allocatedKBytes, true, stackTrace, -1); } synchronized (errors) { errors.addLast(new CounterError(requestName, stackTrace)); if (errors.size() > MAX_ERRORS_COUNT) { errors.removeFirst(); } } } Counter(String name, String iconName);  Counter(String name, String storageName, String iconName, String childCounterName);  Counter(String name, String iconName, Counter childCounter); private  Counter(String name, String storageName, String iconName, String childCounterName,
			ThreadLocal<CounterRequestContext> contextThreadLocal); String getName(); String getStorageName(); String getIconName(); String getChildCounterName(); Date getStartDate(); boolean isDisplayed(); void setDisplayed(boolean displayed); boolean isUsed(); void setUsed(boolean used); void setRequestTransformPattern(Pattern requestTransformPattern); void setMaxRequestsCount(int maxRequestsCount); void bindContextIncludingCpu(String requestName); void bindContext(String requestName, String completeRequestName,
			HttpServletRequest httpRequest, long startCpuTime, long startAllocatedBytes); void unbindContext(); void addRequestForCurrentContext(boolean systemError); void addRequestForCurrentContext(String systemErrorStackTrace); void addRequest(String requestName, long duration, int cpuTime, int allocatedKBytes,
			boolean systemError, long responseSize); void addRequestForSystemError(String requestName, long duration, int cpuTime,
			int allocatedKBytes, String stackTrace); void addRumHit(String requestName, long networkTime, long domProcessing,
			long pageRendering); boolean isErrorCounter(); boolean isJobCounter(); boolean isJspOrStrutsCounter(); boolean isBusinessFacadeCounter(); boolean isRequestIdFromThisCounter(String requestId); void addErrors(List<CounterError> counterErrorList); CounterRequest getCounterRequest(CounterRequestContext context); CounterRequest getCounterRequestByName(String requestName, boolean saveRequestIfAbsent); CounterRequest getCounterRequestById(String requestId); int getRequestsCount(); List<CounterRequest> getRequests(); List<CounterRequest> getOrderedRequests(); List<CounterError> getErrors(); int getErrorsCount(); void clear(); @Override //CHECKSTYLE:OFF Counter clone(); @Override String toString(); static final String HTTP_COUNTER_NAME; static final String ERROR_COUNTER_NAME; static final String LOG_COUNTER_NAME; static final String JSP_COUNTER_NAME; static final String STRUTS_COUNTER_NAME; static final String JSF_COUNTER_NAME; static final String SQL_COUNTER_NAME; static final String JOB_COUNTER_NAME; static final String BUILDS_COUNTER_NAME; static final int MAX_ERRORS_COUNT; }
@Test public void testAddRequestForSystemError() { final CounterRequest request = createCounterRequest(); final Counter errorCounter = new Counter(Counter.ERROR_COUNTER_NAME, null); errorCounter.setMaxRequestsCount(200); errorCounter.addRequestForSystemError(request.getName(), request.getMean(), 0, 0, null); final List<CounterRequest> before = errorCounter.getOrderedRequests(); errorCounter.addRequestForSystemError(request.getName(), request.getMean(), 0, 0, "stacktrace"); final List<CounterRequest> after = errorCounter.getOrderedRequests(); after.get(0).removeHits(request); assertEquals("error requests", before.toString(), after.toString()); int i = 0; while (errorCounter.getRequestsCount() < Counter.MAX_ERRORS_COUNT) { errorCounter.addRequestForSystemError("request a" + i, 1, 0, 0, null); i++; } errorCounter.addRequestForSystemError("request a" + i, 1, 0, 0, null); errorCounter.clear(); i = 0; while (errorCounter.getRequestsCount() < Counter.MAX_ERRORS_COUNT) { errorCounter.bindContextIncludingCpu("request b" + i); errorCounter.addRequestForCurrentContext("stack trace"); i++; } errorCounter.bindContextIncludingCpu("request b" + i); errorCounter.addRequestForCurrentContext("stack trace"); errorCounter.addRequestForCurrentContext("stack trace"); errorCounter.addRequestForCurrentContext(true); }