Repository: wicket Updated Branches: refs/heads/master b708e2b47 -> 410815450
wicket-metrics - refactoring of application lookup Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/41081545 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/41081545 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/41081545 Branch: refs/heads/master Commit: 41081545066bcf1504a920b177bd915bc474c8c1 Parents: b708e2b Author: Tobias Soloschenko <[email protected]> Authored: Tue Mar 29 18:20:46 2016 +0200 Committer: Tobias Soloschenko <[email protected]> Committed: Tue Mar 29 18:20:46 2016 +0200 ---------------------------------------------------------------------- .../apache/wicket/metrics/WicketMetrics.java | 174 +++++++------------ .../wicket/metrics/WicketMetricsSettings.java | 17 +- .../metrics/aspects/WicketFilterInitAspect.java | 47 +++++ .../aspects/WicketFilterRequestCycleAspect.java | 48 ----- .../WicketFilterRequestCycleUrlAspect.java | 64 ------- .../request/WicketFilterRequestCycleAspect.java | 48 +++++ .../WicketFilterRequestCycleUrlAspect.java | 64 +++++++ .../session/SessionCountListenerAspect.java | 4 +- .../main/resources/wicket-metrics.template.xml | 8 +- .../src/docs/guide/monitoring/monitoring_1.gdoc | 31 ++-- .../src/docs/guide/monitoring/monitoring_4.gdoc | 9 +- 11 files changed, 262 insertions(+), 252 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java index dd22f6c..3a01dab 100644 --- a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java @@ -18,6 +18,7 @@ package org.apache.wicket.metrics; import org.apache.wicket.Application; import org.apache.wicket.MetaDataKey; +import org.apache.wicket.WicketRuntimeException; import org.aspectj.lang.ProceedingJoinPoint; import com.codahale.metrics.Counter; @@ -33,28 +34,12 @@ import com.codahale.metrics.Timer.Context; public class WicketMetrics { - private static final String APPLICATION_NAME_PROPERTY = "wicket.metrics.applicationName"; - - private static final String METRICS_STATIC_REGISTRATION = "wicket.metrics.staticRegistration"; /** - * if the application has been resolved + * The name of the filter the metrics are going to collect of */ - private static boolean applicationResolved; + private static String filterName; - /** - * The application - */ - private static Application application; - - /** - * Fall back if the application couldn't be resolved the registry is stored static - */ - private static MetricRegistry metricRegistry; - - /** - * Fall back if the application couldn't be resolved the settings are stored static - */ - private static WicketMetricsSettings wicketMetricsSettings; + private static final String APPLICATION_ERROR = "The application couldn't be resolved, please ensure to apply \"<aspect name=\"org.apache.wicket.metrics.aspects.WicketFilterInitAspect\" />\" to your aspects"; /** The key for metrics registry **/ public static final MetaDataKey<MetricRegistry> METRIC_REGISTRY = new MetaDataKey<MetricRegistry>() @@ -115,7 +100,7 @@ public class WicketMetrics .time(); try { - return joinPoint.proceed(); + return proceedSilent(joinPoint); } finally { @@ -124,7 +109,21 @@ public class WicketMetrics } else { - return joinPoint.proceed(); + return proceedSilent(joinPoint); + } + } + + /** + * Stops the context quietly + * + * @param context + * the context to stop + */ + public void stopQuietly(Context context) + { + if (context != null) + { + context.stop(); } } @@ -145,7 +144,7 @@ public class WicketMetrics } /** - * Creates a histogram of the given arguments + * Creates a count of the given arguments * * @param name * the name of the meter to be marked @@ -158,7 +157,7 @@ public class WicketMetrics * @return the result of the proceeded join point * @throws Throwable */ - public Object counter(String name, ProceedingJoinPoint joinPoint, + public Object count(String name, ProceedingJoinPoint joinPoint, CounterOperation counterOperation, Long value) throws Throwable { WicketMetricsSettings settings = getSettings(); @@ -177,11 +176,7 @@ public class WicketMetrics counter.dec(value); } } - if (joinPoint != null) - { - return joinPoint.proceed(); - } - return null; + return proceedSilent(joinPoint); } @@ -204,25 +199,21 @@ public class WicketMetrics { registry.meter(settings.getPrefix() + name + renderClassName(joinPoint)).mark(); } - if (joinPoint != null) - { - return joinPoint.proceed(); - } - return null; + return proceedSilent(joinPoint); } /** - * Stops the context quietly + * Proceed the join point silent * - * @param context - * the context to stop + * @param joinPoint + * the join point to proceed + * @return the result of the proceeded join point + * @throws Throwable + * if the invocation throws an error */ - public void stopQuietly(Context context) + private Object proceedSilent(ProceedingJoinPoint joinPoint) throws Throwable { - if (context != null) - { - context.stop(); - } + return joinPoint != null ? joinPoint.proceed() : null; } /** @@ -245,29 +236,18 @@ public class WicketMetrics */ public static synchronized MetricRegistry getMetricRegistry() { - if (!applicationResolved) + Application application = Application.get(getFilterName()); + if (application == null) { - application = getApplication(); - applicationResolved = true; + throw new WicketRuntimeException(APPLICATION_ERROR); } - if (application != null && System.getProperty(METRICS_STATIC_REGISTRATION) == null) + MetricRegistry metricRegistry = application.getMetaData(METRIC_REGISTRY); + if (metricRegistry == null) { - MetricRegistry metricRegistry = application.getMetaData(METRIC_REGISTRY); - if (metricRegistry == null) - { - metricRegistry = new MetricRegistry(); - application.setMetaData(METRIC_REGISTRY, metricRegistry); - } - return metricRegistry; - } - else - { - if (WicketMetrics.metricRegistry == null) - { - WicketMetrics.metricRegistry = new MetricRegistry(); - } - return WicketMetrics.metricRegistry; + metricRegistry = new MetricRegistry(); + application.setMetaData(METRIC_REGISTRY, metricRegistry); } + return metricRegistry; } /** @@ -277,77 +257,39 @@ public class WicketMetrics */ public static synchronized WicketMetricsSettings getSettings() { - if (!applicationResolved) - { - application = getApplication(); - applicationResolved = true; - } - if (application != null && System.getProperty(METRICS_STATIC_REGISTRATION) == null) - { - WicketMetricsSettings wicketMetricsSettings = application.getMetaData(METRIC_SETTINGS); - if (wicketMetricsSettings == null) - { - wicketMetricsSettings = new WicketMetricsSettings(); - application.setMetaData(METRIC_SETTINGS, wicketMetricsSettings); - } - return wicketMetricsSettings; - } - else + Application application = Application.get(getFilterName()); + if (application == null) { - if (wicketMetricsSettings == null) - { - wicketMetricsSettings = new WicketMetricsSettings(); - } - return wicketMetricsSettings; + throw new WicketRuntimeException(APPLICATION_ERROR); } - } - - /** - * Gets the application. First it tries to resolve the application with Application.get(String) - * - the String is resolved by the system property "wicket.applicationName". If the application - * can't be found by the corresponding name a Application.get() will be invoked to resolve it. - * - * - * @return the application or null if the application can't be resolved via get() or get(String) - */ - private static Application getApplication() - { - Application application = getApplicationBySystemProperty(); - if (application == null) + WicketMetricsSettings wicketMetricsSettings = application.getMetaData(METRIC_SETTINGS); + if (wicketMetricsSettings == null) { - application = getApplicationFromThreadLocal(); + wicketMetricsSettings = new WicketMetricsSettings(); + wicketMetricsSettings.setPrefix(getFilterName()); + application.setMetaData(METRIC_SETTINGS, wicketMetricsSettings); } - return application; + return wicketMetricsSettings; } /** - * Gets the application from thread local + * Gets the filter name the application should be resolved with * - * @return the application or null if not available + * @return the filter name */ - private static Application getApplicationFromThreadLocal() + public static String getFilterName() { - Application application = null; - if (Application.exists()) - { - application = Application.get(); - } - return application; + return filterName; } /** - * Gets the application by the system property wicket.applicationName + * Sets the filter name the application should be resolved with * - * @return the application or null if not available + * @param filterName + * the filter name */ - private static Application getApplicationBySystemProperty() + public static void setFilterName(String filterName) { - Application application = null; - String applicatioName = System.getProperty(APPLICATION_NAME_PROPERTY); - if (applicatioName != null) - { - application = Application.get(applicatioName); - } - return application; + WicketMetrics.filterName = filterName; } } http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java index 37d5980..c5d3aab 100644 --- a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java @@ -30,7 +30,7 @@ public class WicketMetricsSettings private boolean enabled = true; - private String prefix = "ApacheWicket/"; + private String prefix = "application/"; /** * If the metrics should be enabled @@ -64,6 +64,21 @@ public class WicketMetricsSettings } /** + * Sets the prefix to be used for the statistics + * + * @param prefix + * the prefix to be used + */ + public void setPrefix(String prefix) + { + if (!prefix.endsWith("/")) + { + prefix = prefix + "/"; + } + this.prefix = prefix; + } + + /** * Starts the jmx reporter */ public void startJmxReporter() http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterInitAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterInitAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterInitAspect.java new file mode 100644 index 0000000..6970616 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterInitAspect.java @@ -0,0 +1,47 @@ +package org.apache.wicket.metrics.aspects; + +import javax.servlet.FilterConfig; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * This aspect applies the application to wicket metrics + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class WicketFilterInitAspect +{ + + /** + * Gets the filter name during the initialization + * + * @param joinPoint + * the join point to be proceed + * @return the proceeded outcome of the join point + * @throws Throwable + * if something went wrong + */ + @Around("execution(* org.apache.wicket.protocol.http.WicketFilter.init(..))") + public Object aroundInit(ProceedingJoinPoint joinPoint) throws Throwable + { + Object[] args = joinPoint.getArgs(); + String filterName = null; + if (args.length == 2) + { + FilterConfig filterConfig = (FilterConfig)args[1]; + filterName = filterConfig.getFilterName(); + } + else + { + FilterConfig filterConfig = (FilterConfig)args[0]; + filterName = filterConfig.getFilterName(); + } + WicketMetrics.setFilterName(filterName); + return joinPoint.proceed(); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleAspect.java deleted file mode 100644 index c19af45..0000000 --- a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleAspect.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.metrics.aspects; - -import org.apache.wicket.metrics.WicketMetrics; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; - -/** - * Aspect to handle basic web application information - * - * @author Tobias Soloschenko - */ -@Aspect -public class WicketFilterRequestCycleAspect extends WicketMetrics -{ - - /** - * Collects the time how long a request took to be processed - * - * @param joinPoint - * the joinPoint to be proceed - * @return returns the boolean of the processRequest method - * - * @throws Throwable - * might occur while invoking process request - */ - @Around("execution(* org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(..))") - public Object aroundRequestProcessed(ProceedingJoinPoint joinPoint) throws Throwable - { - return measureTime("core/application/requestCycle", joinPoint); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleUrlAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleUrlAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleUrlAspect.java deleted file mode 100644 index 3cf633e..0000000 --- a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleUrlAspect.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.metrics.aspects; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.wicket.metrics.WicketMetrics; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; - -/** - * Aspect to measure request url time - * - * @author Tobias Soloschenko - */ -@Aspect -public class WicketFilterRequestCycleUrlAspect extends WicketMetrics -{ - /** - * Collects data how often a request has been made against the webapp and counts the time how - * long the request took. Measures the information with the request url - * - * @param joinPoint - * the joinPoint to be proceed - * @return returns the boolean of the processRequest method - * - * @throws Throwable - * might occur while invoking process request - */ - @Around("execution(* org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(..))") - public Object aroundRequestProcessedWithURL(ProceedingJoinPoint joinPoint) throws Throwable - { - Object[] args = joinPoint.getArgs(); - if (args.length >= 3) - { - Object requestAsObject = args[2]; - if (requestAsObject != null && requestAsObject instanceof HttpServletRequest) - { - HttpServletRequest httpServletRequest = (HttpServletRequest)requestAsObject; - String requestUrl = httpServletRequest.getRequestURL().toString(); - String replacedUrl = requestUrl.replace('/', '_'); - replacedUrl = replacedUrl.replace('.', '_'); - replacedUrl = replacedUrl.replaceAll(";jsessionid=.*?(?=\\?|$)", ""); - return measureTime("core/application/request/" + replacedUrl, joinPoint, false); - } - } - return joinPoint.proceed(); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleAspect.java new file mode 100644 index 0000000..d1dd252 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleAspect.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.metrics.aspects.request; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Aspect to handle basic web application information + * + * @author Tobias Soloschenko + */ +@Aspect +public class WicketFilterRequestCycleAspect extends WicketMetrics +{ + + /** + * Collects the time how long a request took to be processed + * + * @param joinPoint + * the joinPoint to be proceed + * @return returns the boolean of the processRequest method + * + * @throws Throwable + * might occur while invoking process request + */ + @Around("execution(* org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(..))") + public Object aroundRequestProcessed(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/application/requestCycle", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleUrlAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleUrlAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleUrlAspect.java new file mode 100644 index 0000000..f60b4c8 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/request/WicketFilterRequestCycleUrlAspect.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.metrics.aspects.request; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Aspect to measure request url time + * + * @author Tobias Soloschenko + */ +@Aspect +public class WicketFilterRequestCycleUrlAspect extends WicketMetrics +{ + /** + * Collects data how often a request has been made against the webapp and counts the time how + * long the request took. Measures the information with the request url + * + * @param joinPoint + * the joinPoint to be proceed + * @return returns the boolean of the processRequest method + * + * @throws Throwable + * might occur while invoking process request + */ + @Around("execution(* org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(..))") + public Object aroundRequestProcessedWithURL(ProceedingJoinPoint joinPoint) throws Throwable + { + Object[] args = joinPoint.getArgs(); + if (args.length >= 3) + { + Object requestAsObject = args[2]; + if (requestAsObject != null && requestAsObject instanceof HttpServletRequest) + { + HttpServletRequest httpServletRequest = (HttpServletRequest)requestAsObject; + String requestUrl = httpServletRequest.getRequestURL().toString(); + String replacedUrl = requestUrl.replace('/', '_'); + replacedUrl = replacedUrl.replace('.', '_'); + replacedUrl = replacedUrl.replaceAll(";jsessionid=.*?(?=\\?|$)", ""); + return measureTime("core/application/request/" + replacedUrl, joinPoint, false); + } + } + return joinPoint.proceed(); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/session/SessionCountListenerAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/session/SessionCountListenerAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/session/SessionCountListenerAspect.java index 7dc8f04..e8a5c36 100644 --- a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/session/SessionCountListenerAspect.java +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/session/SessionCountListenerAspect.java @@ -44,7 +44,7 @@ public class SessionCountListenerAspect extends WicketMetrics public Object aroundInc(ProceedingJoinPoint joinPoint) throws Throwable { Object count = joinPoint.proceed(); - counter("core/session/count", null, CounterOperation.INC, 1L); + count("core/session/count", null, CounterOperation.INC, 1L); return count; } @@ -61,7 +61,7 @@ public class SessionCountListenerAspect extends WicketMetrics public Object aroundDec(ProceedingJoinPoint joinPoint) throws Throwable { Object count = joinPoint.proceed(); - counter("core/session/count", null, CounterOperation.DEC, 1L); + count("core/session/count", null, CounterOperation.DEC, 1L); return count; } http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml b/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml index 5ea5b30..632f257 100644 --- a/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml +++ b/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml @@ -5,6 +5,10 @@ <include within="org.apache.wicket..*"/> </weaver> <aspects> + <!-- required --> + <aspect name="org.apache.wicket.metrics.aspects.WicketFilterInitAspect" /> + + <!-- optional --> <aspect name="org.apache.wicket.metrics.aspects.model.LoadableDetachableModelLoadAspect" /> <aspect name="org.apache.wicket.metrics.aspects.requesthandler.IRequestHandlerDetachAspect" /> <aspect name="org.apache.wicket.metrics.aspects.requesthandler.IRequestHandlerRespondAspect" /> @@ -21,8 +25,8 @@ <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerPrependJavaScriptAspect" /> <aspect name="org.apache.wicket.metrics.aspects.resource.ResourceReferenceCreateAspect" /> <aspect name="org.apache.wicket.metrics.aspects.markup.WicketTagCreateAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.WicketFilterRequestCycleUrlAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.WicketFilterRequestCycleAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.request.WicketFilterRequestCycleUrlAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.request.WicketFilterRequestCycleAspect" /> <aspect name="org.apache.wicket.metrics.aspects.session.SessionCountListenerAspect" /> </aspects> </aspectj> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc b/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc index 7938368..2ee213e 100644 --- a/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc +++ b/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc @@ -21,10 +21,14 @@ This is a little example how to setup wicket-metrics within a Apache Tomcat. <include within="org.apache.wicket..*"/> </weaver> <aspects> + <!-- required --> + <aspect name="org.apache.wicket.metrics.aspects.WicketFilterInitAspect" /> + + <!-- optional --> <aspect name="org.apache.wicket.metrics.aspects.model.LoadableDetachableModelLoadAspect" /> <aspect name="org.apache.wicket.metrics.aspects.requesthandler.IRequestHandlerDetachAspect" /> <aspect name="org.apache.wicket.metrics.aspects.requesthandler.IRequestHandlerRespondAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.resource.IResourceCreateAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.resource.IResourceCreateAspect" /> <aspect name="org.apache.wicket.metrics.aspects.behavior.BehaviorCreateAspect" /> <aspect name="org.apache.wicket.metrics.aspects.component.ComponentCreateAspect" /> <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnConfigureAspect" /> @@ -37,26 +41,20 @@ This is a little example how to setup wicket-metrics within a Apache Tomcat. <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerPrependJavaScriptAspect" /> <aspect name="org.apache.wicket.metrics.aspects.resource.ResourceReferenceCreateAspect" /> <aspect name="org.apache.wicket.metrics.aspects.markup.WicketTagCreateAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.WicketFilterRequestCycleUrlAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.WicketFilterRequestCycleAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.request.WicketFilterRequestCycleUrlAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.request.WicketFilterRequestCycleAspect" /> <aspect name="org.apache.wicket.metrics.aspects.session.SessionCountListenerAspect" /> </aspects> </aspectj> {code} -* If you have set wicket-metrics as dependency you can open "wicket-metrics.template.xml" to get a full template of the "aop.xml" - -* For the weaver options refer to the "AspectJ LTW configuration documentation":https://eclipse.org/aspectj/doc/next/devguide/ltw-configuration.html - * If you use the SessionCountListenerAspect you have to ensure that metadata-complete="false" is set otherwise you have to add the listener yourself: {code} <listener> - <listener-class>org.apache.wicket.metrics.aspects.session.SessionCountListener</listenerclass> + <listener-class>org.apache.wicket.metrics.aspects.session.SessionCountListener</listener-class> </listener> {code} -You also have to clear the session store if you restart the server - otherwise physically stored session will corrupt the data, because the count is initialized with 0. - (5 - optional) To enable the JMX measurement write the following line into your init method of your Application (Now you are able to connect with jvisualvm to your server and have a look at the data): {code} WicketMetrics.getSettings().startJmxReporter(); @@ -72,10 +70,9 @@ To disable measurement: WicketMetrics.getSettings().setEnabled(false); {code} -(6 - optional) There are two system flags which can be applied to the start of the server - --Dwicket.metrics.staticRegistration=true - If this argument is set the wicket metrics settings and the metrics registry are stored in static variables within the WicketMetrics class - this might cause problems in an OSGi environment - --Dwicket.metrics.applicationName=<filtername> - If this argument is set no ThreadLocal access is required, because the Application is looked up via Application#get(String). This property needs to be set if the active sessions counter should be measured with SessionCountListenerAspect because timed out sessions are invalidated in non-HTTP-worker thread and the Wicket thread locals are not available. Caution: this approach could not be used when there are more than one applications in the same web container! - - +*IMPORTANT INFORMATION* +** It is only possible to collect metrics for *one wicket filter per webapp* - don't declare more then one if you want to use wicket-metrics +** The WicketFilterInitAspect is required so that the application can be resolved - otherwise runtime exceptions will be thrown +** If you use the SessionCountListener you have to clear the session store if you restart the server - otherwise physically stored session will corrupt the data, because the count is initialized with 0. +** If you have set wicket-metrics as dependency you can open "wicket-metrics.template.xml" to get a full template of the "aop.xml" +** For the weaver options refer to the AspectJ LTW configuration documentation: https://eclipse.org/aspectj/doc/next/devguide/ltw-configuration.html \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/41081545/wicket-user-guide/src/docs/guide/monitoring/monitoring_4.gdoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/docs/guide/monitoring/monitoring_4.gdoc b/wicket-user-guide/src/docs/guide/monitoring/monitoring_4.gdoc index 3e5c608..22bdd3b 100644 --- a/wicket-user-guide/src/docs/guide/monitoring/monitoring_4.gdoc +++ b/wicket-user-guide/src/docs/guide/monitoring/monitoring_4.gdoc @@ -22,10 +22,15 @@ There are only a two steps required to write own measurements for life data stat <aspectj> <weaver options="-nowarn"> <include within="org.apache.wicket..*"/> - <include within="my.package..*"/> + <include within="my.components.package..*"/> </weaver> <aspects> - <aspect name="my.package.MySpecialAspect" /> + <!-- required --> + <aspect name="org.apache.wicket.metrics.aspects.WicketFilterInitAspect" /> + + <!-- own aspects --> + <aspect name="my.aspect.package.MySpecialAspect" /> + <!-- wickets own metrics --> ..... </aspects>
