-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#271 Implement statistics gathering filter
- Loading branch information
Igor Polevoy
committed
Feb 16, 2016
1 parent
596d29e
commit 0946e90
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
activeweb/src/main/java/org/javalite/activeweb/controller_filters/StatisticsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); | ||
} | ||
} |