Skip to content

Commit

Permalink
#271 Implement statistics gathering filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Polevoy committed Feb 16, 2016
1 parent 596d29e commit 0946e90
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.javalite.activeweb.controller_filters;

import org.javalite.activejdbc.Registry;
import org.javalite.activejdbc.statistics.QueryExecutionEvent;

/**
* This filter will collect statistics about controller/action execution into
* <a href="http://javalite.io/statistics_reporting">Statistics Queue</a> for analysis.
*
*
* @author Igor Polevoy on 2/16/16.
*/
public class StatisticsFilter extends HttpSupportFilter{

private static ThreadLocal<Long> start;

@Override
public void before() {
start.set(System.currentTimeMillis());
}

@Override
public void after() {
Registry.instance().getStatisticsQueue().enqueue(
new QueryExecutionEvent(getRoute().getController() + "#" + getRoute().getActionName(), System.currentTimeMillis() - start.get()));
}
}

0 comments on commit 0946e90

Please sign in to comment.