Wicket Metrics - Moved to experimental / doc improvements / aspects
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f14b1fb4 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f14b1fb4 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f14b1fb4 Branch: refs/heads/master Commit: f14b1fb4aa56f0898a95f1d018ea816731a0b67c Parents: f64a480 Author: Tobias Soloschenko <[email protected]> Authored: Mon Mar 14 18:16:53 2016 +0100 Committer: Tobias Soloschenko <[email protected]> Committed: Wed Mar 16 17:55:14 2016 +0100 ---------------------------------------------------------------------- pom.xml | 5 +- wicket-experimental/pom.xml | 2 +- wicket-experimental/wicket-atmosphere/pom.xml | 3 +- wicket-experimental/wicket-metrics/pom.xml | 49 ++++++ .../apache/wicket/metrics/WicketMetrics.java | 168 +++++++++++++++++++ .../wicket/metrics/WicketMetricsSettings.java | 87 ++++++++++ .../aspects/WicketFilterRequestCycleAspect.java | 49 ++++++ .../IPartialPageRequestHandlerAddAspect.java | 43 +++++ ...ageRequestHandlerAppendJavaScriptAspect.java | 45 +++++ ...geRequestHandlerPrependJavaScriptAspect.java | 44 +++++ .../aspects/behavior/BehaviorCreateAspect.java | 47 ++++++ .../component/ComponentCreateAspect.java | 47 ++++++ .../component/ComponentOnConfigureAspect.java | 48 ++++++ .../component/ComponentOnDetachAspect.java | 47 ++++++ .../component/ComponentOnInitializeAspect.java | 47 ++++++ .../component/ComponentOnRenderAspect.java | 48 ++++++ .../ComponentSetResponsePageAspect.java | 42 +++++ .../aspects/markup/WicketTagCreateAspect.java | 43 +++++ .../LoadableDetachableModelLoadAspect.java | 32 ++++ .../IRequestHandlerDetachAspect.java | 31 ++++ .../IRequestHandlerRespondAspect.java | 31 ++++ .../aspects/resource/IResourceCreateAspect.java | 30 ++++ .../resource/ResourceReferenceCreateAspect.java | 48 ++++++ .../main/resources/wicket-metrics.template.xml | 26 +++ wicket-metrics/pom.xml | 49 ------ .../apache/wicket/metrics/WicketMetrics.java | 168 ------------------- .../wicket/metrics/WicketMetricsSettings.java | 87 ---------- .../wicket/metrics/aspects/BehaviorAspect.java | 47 ------ .../wicket/metrics/aspects/ComponentAspect.java | 122 -------------- .../IPartialPageRequestHandlerAspect.java | 68 -------- .../aspects/ResourceReferenceAspect.java | 48 ------ .../metrics/aspects/WicketFilterAspect.java | 49 ------ .../src/docs/guide/monitoring/monitoring_1.gdoc | 30 +++- .../src/docs/guide/monitoring/monitoring_2.gdoc | 31 +++- .../src/docs/guide/monitoring/monitoring_4.gdoc | 33 ++++ wicket-user-guide/src/docs/guide/toc.yml | 3 +- 36 files changed, 1136 insertions(+), 661 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f4f84a1..05d565f 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,6 @@ <module>wicket-bean-validation</module> <module>wicket-cdi-1.1</module> <module>wicket-user-guide</module> - <module>wicket-metrics</module> </modules> <properties> <!-- Encoding --> @@ -406,13 +405,13 @@ <type>jar</type> </dependency> <dependency> - <groupId>org.apache.wicket</groupId> + <groupId>org.apache.wicket.experimental.wicket8</groupId> <artifactId>wicket-metrics</artifactId> <version>8.0.0-SNAPSHOT</version> <type>jar</type> </dependency> <dependency> - <groupId>org.apache.wicket.experimental.wicket7</groupId> + <groupId>org.apache.wicket.experimental.wicket8</groupId> <artifactId>wicket-atmosphere</artifactId> <version>0.24-SNAPSHOT</version> <type>jar</type> http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-experimental/pom.xml b/wicket-experimental/pom.xml index e77b7d4..9f9922d 100644 --- a/wicket-experimental/pom.xml +++ b/wicket-experimental/pom.xml @@ -23,7 +23,7 @@ <version>8.0.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <groupId>org.apache.wicket.experimental.wicket7</groupId> + <groupId>org.apache.wicket.experimental.wicket8</groupId> <artifactId>wicket-experimental</artifactId> <packaging>pom</packaging> <name>Wicket-Experimental</name> http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-atmosphere/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/pom.xml b/wicket-experimental/wicket-atmosphere/pom.xml index dd8c108..bca4c36 100644 --- a/wicket-experimental/wicket-atmosphere/pom.xml +++ b/wicket-experimental/wicket-atmosphere/pom.xml @@ -18,13 +18,12 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.apache.wicket.experimental.wicket7</groupId> + <groupId>org.apache.wicket.experimental.wicket8</groupId> <artifactId>wicket-experimental</artifactId> <version>8.0.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>wicket-atmosphere</artifactId> - <version>0.24-SNAPSHOT</version> <packaging>jar</packaging> <name>Wicket-Atmosphere</name> <description>Wicket-Atmosphere provides integration of the Atmosphere Framework in Wicket.</description> http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/pom.xml b/wicket-experimental/wicket-metrics/pom.xml new file mode 100644 index 0000000..3ae5827 --- /dev/null +++ b/wicket-experimental/wicket-metrics/pom.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.wicket.experimental.wicket8</groupId> + <artifactId>wicket-experimental</artifactId> + <version>8.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>wicket-metrics</artifactId> + <packaging>jar</packaging> + <name>Wicket Metrics</name> + <description> + Wicketâs implementation to show metric information + about web applications build on the web framework. + </description> + <dependencies> + <dependency> + <groupId>org.apache.wicket</groupId> + <artifactId>wicket-core</artifactId> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>io.dropwizard.metrics</groupId> + <artifactId>metrics-core</artifactId> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/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 new file mode 100644 index 0000000..4b4704d --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java @@ -0,0 +1,168 @@ +/* + * 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; + +import org.apache.wicket.Application; +import org.apache.wicket.MetaDataKey; +import org.aspectj.lang.ProceedingJoinPoint; + +import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.Timer.Context; + +/** + * Base aspect provides access to the metric registry + * + * @author Tobias Soloschenko + * + */ +public class WicketMetrics +{ + + /** The key for metrics registry **/ + public static final MetaDataKey<MetricRegistry> METRIC_REGISTRY = new MetaDataKey<MetricRegistry>() + { + private static final long serialVersionUID = 1L; + }; + + /** The key for metrics registry **/ + public static final MetaDataKey<WicketMetricsSettings> METRIC_SETTINGS = new MetaDataKey<WicketMetricsSettings>() + { + private static final long serialVersionUID = 1L; + }; + + /** + * Simply measure the time for a {@literal @}around + * + * @param name + * the name of the timer context + * @param joinPoint + * the joinPoint to be proceed + * @return the value of the join point + * @throws Throwable + * if there is an exception while execution + */ + public Object measureTime(String name, ProceedingJoinPoint joinPoint) throws Throwable + { + WicketMetricsSettings settings = getSettings(); + MetricRegistry registry = getMetricRegistry(); + + if (settings.isEnabled()) + { + Context context = registry + .timer(settings.getPrefix() + name + renderClassName(joinPoint)).time(); + try + { + return joinPoint.proceed(); + } + finally + { + stopQuietly(context); + } + } + else + { + return joinPoint.proceed(); + } + } + + /** + * Marks the meter with the given name + * + * @param name + * the name of the meter to be marked + * @param joinPoint + * the join point + * @return the result of the proceeded join point + * @throws Throwable + */ + public Object mark(String name, ProceedingJoinPoint joinPoint) throws Throwable + { + WicketMetricsSettings settings = getSettings(); + MetricRegistry registry = getMetricRegistry(); + + if (settings.isEnabled()) + { + registry.meter(settings.getPrefix() + name + renderClassName(joinPoint)).mark(); + } + if (joinPoint != null) + { + return joinPoint.proceed(); + } + return null; + } + + /** + * Stops the context quietly + * + * @param context + * the context to stop + */ + public void stopQuietly(Context context) + { + if (context != null) + { + context.stop(); + } + } + + /** + * Renders the class name of the given join point + * + * @param joinPoint + * the join point to get the class of + * @return the class name representation + */ + public String renderClassName(ProceedingJoinPoint joinPoint) + { + return joinPoint != null + ? "/" + joinPoint.getTarget().getClass().getName().replace('.', '_') : ""; + } + + /** + * Gets the metric registry + * + * @return the metric registry + */ + private static synchronized MetricRegistry getMetricRegistry() + { + Application application = Application.get(); + MetricRegistry metricRegistry = application.getMetaData(METRIC_REGISTRY); + if (metricRegistry == null) + { + metricRegistry = new MetricRegistry(); + application.setMetaData(METRIC_REGISTRY, metricRegistry); + } + return metricRegistry; + } + + /** + * Gets the wicket metrics settings + * + * @return the wicket metrics settings + */ + private static synchronized WicketMetricsSettings getSettings() + { + Application application = Application.get(); + WicketMetricsSettings metricRegistry = application.getMetaData(METRIC_SETTINGS); + if (metricRegistry == null) + { + metricRegistry = new WicketMetricsSettings(); + application.setMetaData(METRIC_SETTINGS, metricRegistry); + } + return metricRegistry; + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/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 new file mode 100644 index 0000000..1bbaef2 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java @@ -0,0 +1,87 @@ +/* + * 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; + +import org.apache.wicket.Application; + +import com.codahale.metrics.JmxReporter; +import com.codahale.metrics.MetricRegistry; + +/** + * Settings to configure wicket metrics + * + * @author Tobias Soloschenko + * + */ +public class WicketMetricsSettings +{ + + private boolean enabled = true; + + private String prefix = "ApacheWicket/"; + + /** + * If the metrics should be enabled + * + * @param enabled + * if the metrics should be enabled + */ + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + /** + * If the wicket metrics are enabled + * + * @return if the wicket metrics are enabled + */ + public boolean isEnabled() + { + return enabled; + } + + /** + * Gets the prefix. + * + * @return the prefix + */ + public String getPrefix() + { + return prefix; + } + + /** + * Starts the jmx reporter + */ + public void startJmxReporter() + { + MetricRegistry metricRegistry = Application.get() + .getMetaData(WicketMetrics.METRIC_REGISTRY); + JmxReporter.forRegistry(metricRegistry).build().start(); + } + + /** + * Stops the jmx reporter + */ + public void stopJmxReporter() + { + MetricRegistry metricRegistry = Application.get() + .getMetaData(WicketMetrics.METRIC_REGISTRY); + JmxReporter.forRegistry(metricRegistry).build().stop(); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/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 new file mode 100644 index 0000000..f7f7c0c --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterRequestCycleAspect.java @@ -0,0 +1,49 @@ +/* + * 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 data how often a request has been made against the webapp and counts the time how + * long the request remains + * + * @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/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAddAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAddAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAddAspect.java new file mode 100644 index 0000000..f14fe6d --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAddAspect.java @@ -0,0 +1,43 @@ +/* + * 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.ajax; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Aspect which measures ajax request targets components to be requested for repaint + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class IPartialPageRequestHandlerAddAspect extends WicketMetrics +{ + /** + * Collects data how often components calls add + * + * @throws Throwable + * might occur while invoking add + */ + @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.add(..))") + public void beforeAdd() throws Throwable + { + mark("core/ajax/add", null); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAppendJavaScriptAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAppendJavaScriptAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAppendJavaScriptAspect.java new file mode 100644 index 0000000..233c639 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerAppendJavaScriptAspect.java @@ -0,0 +1,45 @@ +/* + * 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.ajax; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Aspect which measures ajax request targets append java script metrics + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class IPartialPageRequestHandlerAppendJavaScriptAspect extends WicketMetrics +{ + + /** + * Collects data how often components calls appendJavaScript + * + * @throws Throwable + * might occur while invoking appendJavaScript + */ + @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.appendJavaScript(..))") + public void beforeAppendJavaScript() throws Throwable + { + mark("core/ajax/appendJavaScript", null); + } + +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerPrependJavaScriptAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerPrependJavaScriptAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerPrependJavaScriptAspect.java new file mode 100644 index 0000000..a1d183f --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ajax/IPartialPageRequestHandlerPrependJavaScriptAspect.java @@ -0,0 +1,44 @@ +/* + * 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.ajax; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Aspect measures checks ajax request targets prepent java script + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class IPartialPageRequestHandlerPrependJavaScriptAspect extends WicketMetrics +{ + + /** + * Collects data how often components calls prependJavaScript + * + * @throws Throwable + * might occur while invoking prependJavaScript + */ + @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.prependJavaScript(..))") + public void beforePrependJavaScript() throws Throwable + { + mark("core/ajax/prependJavaScript", null); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/behavior/BehaviorCreateAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/behavior/BehaviorCreateAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/behavior/BehaviorCreateAspect.java new file mode 100644 index 0000000..767d894 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/behavior/BehaviorCreateAspect.java @@ -0,0 +1,47 @@ +/* + * 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.behavior; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Measures everything about behaviors + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class BehaviorCreateAspect extends WicketMetrics +{ + /** + * Collects data how often a behavior is created + * + * @param joinPoint + * the join point (behavior) which is created + * @return the result of constructor + * @throws Throwable + * might occur while creating a new behavior + */ + @Around("execution(org.apache.wicket.behavior.Behavior.new(..))") + public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable + { + return mark("core/behavior/create", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentCreateAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentCreateAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentCreateAspect.java new file mode 100644 index 0000000..318ef31 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentCreateAspect.java @@ -0,0 +1,47 @@ +/* + * 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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Gets information how often different components are created + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentCreateAspect extends WicketMetrics +{ + + /** + * Collects data how often components are created + * + * @param joinPoint + * the join point (component) which is created + * @return the object returned from the join point + * @throws Throwable + * might occur while constructing a new component + */ + @Around("execution(org.apache.wicket.Component.new(..))") + public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/component/create", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnConfigureAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnConfigureAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnConfigureAspect.java new file mode 100644 index 0000000..7058567 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnConfigureAspect.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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Gets information how often different components are configured + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentOnConfigureAspect extends WicketMetrics +{ + + /** + * Collects data how often components calls onConfigure + * + * @param joinPoint + * the join point (component) which is configured + * @return the object returned from the join point + * + * @throws Throwable + * might occur while invoking onConfigure + */ + @Around("execution(* org.apache.wicket.Component.onConfigure(..))") + public Object aroundOnConfigure(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/component/configure", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnDetachAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnDetachAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnDetachAspect.java new file mode 100644 index 0000000..1abfd53 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnDetachAspect.java @@ -0,0 +1,47 @@ +/* + * 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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Gets information how often different components are detached + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentOnDetachAspect extends WicketMetrics +{ + + /** + * Collects data how often components calls onDetach + * + * @param joinPoint + * the join point (component) which is calling detach + * @return the object returned from the join point + * @throws Throwable + * might occur while invoking onDetach + */ + @Around("execution(* org.apache.wicket.Component.onDetach(..))") + public Object arroundOnDetach(ProceedingJoinPoint joinPoint) throws Throwable + { + return mark("core/component/detach", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnInitializeAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnInitializeAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnInitializeAspect.java new file mode 100644 index 0000000..d2cca54 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnInitializeAspect.java @@ -0,0 +1,47 @@ +/* + * 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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Gets information how often different components are initialized + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentOnInitializeAspect extends WicketMetrics +{ + /** + * Collects data how often components calls onInitialize + * + * @param joinPoint + * the join point (component) which is initialized + * @return the object returned from the join point + * + * @throws Throwable + * might occur while invoking onInitialize + */ + @Around("execution(* org.apache.wicket.Component.onInitialize(..))") + public Object aroundOnInitialize(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/component/initialize", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnRenderAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnRenderAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnRenderAspect.java new file mode 100644 index 0000000..ad9bdfd --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentOnRenderAspect.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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Gets information how often different components are rendered + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentOnRenderAspect extends WicketMetrics +{ + + /** + * Collects data how often components are rendered + * + * @param joinPoint + * the join point (component) which is rendered + * @return the object returned from the join point + * @throws Throwable + * might occur while onRender + */ + @Around("execution(* org.apache.wicket.Component.onRender(..))") + public Object aroundOnRender(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/component/render", joinPoint); + } + +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentSetResponsePageAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentSetResponsePageAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentSetResponsePageAspect.java new file mode 100644 index 0000000..7a80204 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/component/ComponentSetResponsePageAspect.java @@ -0,0 +1,42 @@ +/* + * 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.component; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Gets information how often different components are calling setResponsePage + * + * @author Tobias Soloschenko + */ +@Aspect +public class ComponentSetResponsePageAspect extends WicketMetrics +{ + /** + * Collects data how often components redirect to another page + * + * @throws Throwable + * might occur while invoking setResponsePage + */ + @Before("call(* org.apache.wicket.Component.setResponsePage(..))") + public void beforeResponsePage() throws Throwable + { + mark("core/component/redirect", null); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/markup/WicketTagCreateAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/markup/WicketTagCreateAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/markup/WicketTagCreateAspect.java new file mode 100644 index 0000000..2a2751a --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/markup/WicketTagCreateAspect.java @@ -0,0 +1,43 @@ +/* + * 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.markup; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +/** + * Measures information about wicket tags + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class WicketTagCreateAspect extends WicketMetrics +{ + /** + * Collects data how often components redirect to another page + * + * @throws Throwable + * might occur while invoking setResponsePage + */ + @Before("call(org.apache.wicket.markup.WicketTag.new(..))") + public void beforeResponsePage() throws Throwable + { + mark("core/tags/wicket/create", null); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/model/LoadableDetachableModelLoadAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/model/LoadableDetachableModelLoadAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/model/LoadableDetachableModelLoadAspect.java new file mode 100644 index 0000000..5b83de5 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/model/LoadableDetachableModelLoadAspect.java @@ -0,0 +1,32 @@ +package org.apache.wicket.metrics.aspects.model; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Measures information about how long the loading process of the ldm take + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class LoadableDetachableModelLoadAspect extends WicketMetrics +{ + + /** + * Collects data how often a request handler calls detach + * + * @param joinPoint + * the join point (request handler) which processes the response + * @return the object returned from the join point + * @throws Throwable + * might occur while detach + */ + @Around("execution(* org.apache.wicket.model.LoadableDetachableModel.load())") + public Object aroundOnRender(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/model/loadabledetachablemodel/load", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerDetachAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerDetachAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerDetachAspect.java new file mode 100644 index 0000000..7c658b4 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerDetachAspect.java @@ -0,0 +1,31 @@ +package org.apache.wicket.metrics.aspects.requesthandler; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Measures information about request handlers detach + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class IRequestHandlerDetachAspect extends WicketMetrics +{ + /** + * Collects data how often a request handler calls detach + * + * @param joinPoint + * the join point (request handler) which processes the response + * @return the object returned from the join point + * @throws Throwable + * might occur while detach + */ + @Around("execution(* org.apache.wicket.request.IRequestHandler.detach(..))") + public Object aroundOnRender(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/requesthandler/detach", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerRespondAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerRespondAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerRespondAspect.java new file mode 100644 index 0000000..45387f2 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/requesthandler/IRequestHandlerRespondAspect.java @@ -0,0 +1,31 @@ +package org.apache.wicket.metrics.aspects.requesthandler; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Measures information about request handlers respond + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class IRequestHandlerRespondAspect extends WicketMetrics +{ + /** + * Collects data how often a request handler processes its response + * + * @param joinPoint + * the join point (request handler) which processes the response + * @return the object returned from the join point + * @throws Throwable + * might occur while respond + */ + @Around("execution(* org.apache.wicket.request.IRequestHandler.respond(..))") + public Object aroundOnRender(ProceedingJoinPoint joinPoint) throws Throwable + { + return measureTime("core/requesthandler/respond", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/IResourceCreateAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/IResourceCreateAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/IResourceCreateAspect.java new file mode 100644 index 0000000..7a5f1f7 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/IResourceCreateAspect.java @@ -0,0 +1,30 @@ +package org.apache.wicket.metrics.aspects.resource; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Measures how often a resource is created + * @author Tobias Soloschenko + * + */ +@Aspect +public class IResourceCreateAspect extends WicketMetrics +{ + /** + * Collects data how often a resource reference is created + * + * @param joinPoint + * the join point (resource reference) which is created + * @return the result of constructor + * @throws Throwable + * might occur while creating a new resource reference + */ + @Around("execution(org.apache.wicket.request.resource.IResource.new(..))") + public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable + { + return mark("core/resource/resource/create", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/ResourceReferenceCreateAspect.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/ResourceReferenceCreateAspect.java b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/ResourceReferenceCreateAspect.java new file mode 100644 index 0000000..b14af58 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/resource/ResourceReferenceCreateAspect.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.resource; + +import org.apache.wicket.metrics.WicketMetrics; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * Collects basic information about pages + * + * @author Tobias Soloschenko + * + */ +@Aspect +public class ResourceReferenceCreateAspect extends WicketMetrics +{ + + /** + * Collects data how often a resource reference is created + * + * @param joinPoint + * the join point (resource reference) which is created + * @return the result of constructor + * @throws Throwable + * might occur while creating a new resource reference + */ + @Around("execution(org.apache.wicket.request.resource.ResourceReference.new(..))") + public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable + { + return mark("core/resource/reference/create", joinPoint); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/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 new file mode 100644 index 0000000..e59cb51 --- /dev/null +++ b/wicket-experimental/wicket-metrics/src/main/resources/wicket-metrics.template.xml @@ -0,0 +1,26 @@ +<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> +<aspectj> + <weaver options="-nowarn"> + <include within="org.apache.wicket..*"/> + <include within="com.fluentsqaure..*"/> + </weaver> + <aspects> + <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.behavior.BehaviorCreateAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentCreateAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnConfigureAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnDetachAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnInitializeAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnRenderAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentSetResponsePageAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerAddAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerAppendJavaScriptAspect" /> + <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.WicketFilterRequestCycleAspect" /> + </aspects> +</aspectj> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-metrics/pom.xml b/wicket-metrics/pom.xml deleted file mode 100644 index a3a6a5b..0000000 --- a/wicket-metrics/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.wicket</groupId> - <artifactId>wicket-parent</artifactId> - <version>8.0.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>wicket-metrics</artifactId> - <packaging>jar</packaging> - <name>Wicket Metrics</name> - <description> - Wicketâs implementation to show metric information - about web applications build on the web framework. - </description> - <dependencies> - <dependency> - <groupId>org.apache.wicket</groupId> - <artifactId>wicket-core</artifactId> - </dependency> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>io.dropwizard.metrics</groupId> - <artifactId>metrics-core</artifactId> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java deleted file mode 100644 index 51e55c5..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetrics.java +++ /dev/null @@ -1,168 +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; - -import org.apache.wicket.Application; -import org.apache.wicket.MetaDataKey; -import org.aspectj.lang.ProceedingJoinPoint; - -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Timer.Context; - -/** - * Base aspect provides access to the metric registry - * - * @author Tobias Soloschenko - * - */ -public class WicketMetrics -{ - - /** The key for metrics registry **/ - public static final MetaDataKey<MetricRegistry> METRIC_REGISTRY = new MetaDataKey<MetricRegistry>() - { - private static final long serialVersionUID = 1L; - }; - - /** The key for metrics registry **/ - public static final MetaDataKey<WicketMetricsSettings> METRIC_SETTINGS = new MetaDataKey<WicketMetricsSettings>() - { - private static final long serialVersionUID = 1L; - }; - - /** - * Simply measure the time for a {@literal @}around - * - * @param name - * the name of the timer context - * @param joinPoint - * the joinPoint to be proceed - * @return the value of the join point - * @throws Throwable - * if there is an exception while execution - */ - public Object measureTime(String name, ProceedingJoinPoint joinPoint) throws Throwable - { - WicketMetricsSettings settings = getSettings(); - MetricRegistry registry = getMetricRegistry(); - - if (settings.isEnabled()) - { - Context context = registry - .timer(settings.getPrefix() + name + renderClassName(joinPoint)).time(); - try - { - return joinPoint.proceed(); - } - finally - { - stopQuietly(context); - } - } - else - { - return joinPoint.proceed(); - } - } - - /** - * Marks the meter with the given name - * - * @param name - * the name of the meter to be marked - * @param joinPoint - * the join point - * @return the result of the proceeded join point - * @throws Throwable - */ - public Object mark(String name, ProceedingJoinPoint joinPoint) throws Throwable - { - WicketMetricsSettings settings = getSettings(); - MetricRegistry registry = getMetricRegistry(); - - if (settings.isEnabled()) - { - registry.meter(settings.getPrefix() + name + renderClassName(joinPoint)).mark(); - } - if (joinPoint != null) - { - return joinPoint.proceed(); - } - return null; - } - - /** - * Stops the context quietly - * - * @param context - * the context to stop - */ - public void stopQuietly(Context context) - { - if (context != null) - { - context.stop(); - } - } - - /** - * Renders the class name of the given join point - * - * @param joinPoint - * the join point to get the class of - * @return the class name representation - */ - public String renderClassName(ProceedingJoinPoint joinPoint) - { - return joinPoint != null - ? "/" + joinPoint.getTarget().getClass().getName().replace('.', '_') : ""; - } - - /** - * Gets the metric registry - * - * @return the metric registry - */ - private MetricRegistry getMetricRegistry() - { - Application application = Application.get(); - MetricRegistry metricRegistry = application.getMetaData(METRIC_REGISTRY); - if (metricRegistry == null) - { - metricRegistry = new MetricRegistry(); - application.setMetaData(METRIC_REGISTRY, metricRegistry); - } - return metricRegistry; - } - - /** - * Gets the wicket metrics settings - * - * @return the wicket metrics settings - */ - private WicketMetricsSettings getSettings() - { - Application application = Application.get(); - WicketMetricsSettings metricRegistry = application.getMetaData(METRIC_SETTINGS); - if (metricRegistry == null) - { - metricRegistry = new WicketMetricsSettings(); - application.setMetaData(METRIC_SETTINGS, metricRegistry); - } - return metricRegistry; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java deleted file mode 100644 index 1bbaef2..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/WicketMetricsSettings.java +++ /dev/null @@ -1,87 +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; - -import org.apache.wicket.Application; - -import com.codahale.metrics.JmxReporter; -import com.codahale.metrics.MetricRegistry; - -/** - * Settings to configure wicket metrics - * - * @author Tobias Soloschenko - * - */ -public class WicketMetricsSettings -{ - - private boolean enabled = true; - - private String prefix = "ApacheWicket/"; - - /** - * If the metrics should be enabled - * - * @param enabled - * if the metrics should be enabled - */ - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * If the wicket metrics are enabled - * - * @return if the wicket metrics are enabled - */ - public boolean isEnabled() - { - return enabled; - } - - /** - * Gets the prefix. - * - * @return the prefix - */ - public String getPrefix() - { - return prefix; - } - - /** - * Starts the jmx reporter - */ - public void startJmxReporter() - { - MetricRegistry metricRegistry = Application.get() - .getMetaData(WicketMetrics.METRIC_REGISTRY); - JmxReporter.forRegistry(metricRegistry).build().start(); - } - - /** - * Stops the jmx reporter - */ - public void stopJmxReporter() - { - MetricRegistry metricRegistry = Application.get() - .getMetaData(WicketMetrics.METRIC_REGISTRY); - JmxReporter.forRegistry(metricRegistry).build().stop(); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/BehaviorAspect.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/BehaviorAspect.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/BehaviorAspect.java deleted file mode 100644 index 94cc60c..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/BehaviorAspect.java +++ /dev/null @@ -1,47 +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; - -/** - * Measures everything about behaviors - * - * @author Tobias Soloschenko - * - */ -@Aspect -public class BehaviorAspect extends WicketMetrics -{ - /** - * Collects data how often a behavior is created - * - * @param joinPoint - * the join point (behavior) which is created - * @return the result of constructor - * @throws Throwable - * might occur while creating a new behavior - */ - @Around("execution(org.apache.wicket.behavior.Behavior.new(..))") - public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable - { - return mark("core/behavior/create", joinPoint); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ComponentAspect.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ComponentAspect.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ComponentAspect.java deleted file mode 100644 index e046a63..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ComponentAspect.java +++ /dev/null @@ -1,122 +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; -import org.aspectj.lang.annotation.Before; - -/** - * Gets information how often different components are rendered - * - * @author Tobias Soloschenko - */ -@Aspect -public class ComponentAspect extends WicketMetrics -{ - - /** - * Collects data how often components are rendered - * - * @param joinPoint - * the join point (component) which is rendered - * @return the object returned from the join point - * @throws Throwable - * might occur while onRender - */ - @Around("execution(* org.apache.wicket.Component.onRender(..))") - public Object aroundOnRender(ProceedingJoinPoint joinPoint) throws Throwable - { - return measureTime("core/component/render", joinPoint); - } - - /** - * Collects data how often components are created - * - * @param joinPoint - * the join point (component) which is created - * @return the object returned from the join point - * @throws Throwable - * might occur while constructing a new component - */ - @Around("execution(org.apache.wicket.Component.new(..))") - public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable - { - return measureTime("core/component/create", joinPoint); - } - - /** - * Collects data how often components calls onConfigure - * - * @param joinPoint - * the join point (component) which is configured - * @return the object returned from the join point - * - * @throws Throwable - * might occur while invoking onConfigure - */ - @Around("execution(* org.apache.wicket.Component.onConfigure(..))") - public Object aroundOnConfigure(ProceedingJoinPoint joinPoint) throws Throwable - { - return measureTime("core/component/configure", joinPoint); - } - - /** - * Collects data how often components calls onInitialize - * - * @param joinPoint - * the join point (component) which is initialized - * @return the object returned from the join point - * - * @throws Throwable - * might occur while invoking onInitialize - */ - @Around("execution(* org.apache.wicket.Component.onInitialize(..))") - public Object aroundOnInitialize(ProceedingJoinPoint joinPoint) throws Throwable - { - return measureTime("core/component/initialize", joinPoint); - } - - /** - * Collects data how often components calls onDetach - * - * @param joinPoint - * the join point (component) which is calling detach - * @return the object returned from the join point - * @throws Throwable - * might occur while invoking onDetach - */ - @Around("execution(* org.apache.wicket.Component.onDetach(..))") - public Object arroundOnDetach(ProceedingJoinPoint joinPoint) throws Throwable - { - return mark("core/component/detach", joinPoint); - } - - /** - * Collects data how often components redirect to another page - * - * @throws Throwable - * might occur while invoking setResponsePage - */ - @Before("call(* org.apache.wicket.Component.setResponsePage(..))") - public void beforeResponsePage() throws Throwable - { - mark("core/component/redirect", null); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/IPartialPageRequestHandlerAspect.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/IPartialPageRequestHandlerAspect.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/IPartialPageRequestHandlerAspect.java deleted file mode 100644 index 24cb2a1..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/IPartialPageRequestHandlerAspect.java +++ /dev/null @@ -1,68 +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.annotation.Aspect; -import org.aspectj.lang.annotation.Before; - -/** - * Aspect which checks ajax request targets - * - * @author Tobias Soloschenko - * - */ -@Aspect -public class IPartialPageRequestHandlerAspect extends WicketMetrics -{ - /** - * Collects data how often components calls add - * - * @throws Throwable - * might occur while invoking add - */ - @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.add(..))") - public void beforeAdd() throws Throwable - { - mark("core/ajax/add", null); - } - - /** - * Collects data how often components calls prependJavaScript - * - * @throws Throwable - * might occur while invoking prependJavaScript - */ - @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.prependJavaScript(..))") - public void beforePrependJavaScript() throws Throwable - { - mark("core/ajax/prependJavaScript", null); - } - - /** - * Collects data how often components calls appendJavaScript - * - * @throws Throwable - * might occur while invoking appendJavaScript - */ - @Before("call(* org.apache.wicket.core.request.handler.IPartialPageRequestHandler.appendJavaScript(..))") - public void beforeAppendJavaScript() throws Throwable - { - mark("core/ajax/appendJavaScript", null); - } - -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ResourceReferenceAspect.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ResourceReferenceAspect.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ResourceReferenceAspect.java deleted file mode 100644 index cd11e54..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/ResourceReferenceAspect.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; - -/** - * Collects basic information about pages - * - * @author Tobias Soloschenko - * - */ -@Aspect -public class ResourceReferenceAspect extends WicketMetrics -{ - - /** - * Collects data how often a resource reference is created - * - * @param joinPoint - * the join point (resource reference) which is created - * @return the result of constructor - * @throws Throwable - * might occur while creating a new resource reference - */ - @Around("execution(org.apache.wicket.request.resource.ResourceReference.new(..))") - public Object aroundNew(ProceedingJoinPoint joinPoint) throws Throwable - { - return mark("core/resource/create", joinPoint); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterAspect.java ---------------------------------------------------------------------- diff --git a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterAspect.java b/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterAspect.java deleted file mode 100644 index c71430c..0000000 --- a/wicket-metrics/src/main/java/org/apache/wicket/metrics/aspects/WicketFilterAspect.java +++ /dev/null @@ -1,49 +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 WicketFilterAspect extends WicketMetrics -{ - - /** - * Collects data how often a request has been made against the webapp and counts the time how - * long the request remains - * - * @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/f14b1fb4/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 6d2dab5..d63186d 100644 --- a/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc +++ b/wicket-user-guide/src/docs/guide/monitoring/monitoring_1.gdoc @@ -3,7 +3,7 @@ This is a little example how to setup wicket-metrics within a Apache Tomcat. (1) Add the maven dependency to your project {code} <dependency> - <groupId>org.apache.wicket</groupId> + <groupId>org.apache.wicket.experimental.wicket8</groupId> <artifactId>wicket-metrics</artifactId> <version>${wicket.version}</version> </dependency> @@ -13,7 +13,7 @@ This is a little example how to setup wicket-metrics within a Apache Tomcat. (3) Add the java agent to the jvm start options of your tomcat: -javaagent:/pathToServer/lib/aspectjweaver-x.x.x.jar -(4) Add an aop.xml to your project with the metrics you want to use (aspect tags) - if you don't want to enable a metrics just remove the aspect tag: +(4) Add an aop.xml to your project's META-INF folder at the root of your classpath with the metrics you want to use (aspect tags) - if you don't want to enable a metrics just remove the aspect tag: {code} <!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> <aspectj> @@ -21,15 +21,31 @@ This is a little example how to setup wicket-metrics within a Apache Tomcat. <include within="org.apache.wicket..*"/> </weaver> <aspects> - <aspect name="org.apache.wicket.metrics.aspects.BehaviorAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.IPartialPageRequestHandlerAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.ComponentAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.WicketFilterAspect" /> - <aspect name="org.apache.wicket.metrics.aspects.ResourceReferenceAspect" /> + <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.behavior.BehaviorCreateAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentCreateAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnConfigureAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnDetachAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnInitializeAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentOnRenderAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.component.ComponentSetResponsePageAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerAddAspect" /> + <aspect name="org.apache.wicket.metrics.aspects.ajax.IPartialPageRequestHandlerAppendJavaScriptAspect" /> + <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.WicketFilterRequestCycleAspect" /> </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 + (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} Application.get().getMetaData(WicketMetrics.METRIC_SETTINGS).startJmxReporter(); http://git-wip-us.apache.org/repos/asf/wicket/blob/f14b1fb4/wicket-user-guide/src/docs/guide/monitoring/monitoring_2.gdoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/docs/guide/monitoring/monitoring_2.gdoc b/wicket-user-guide/src/docs/guide/monitoring/monitoring_2.gdoc index be330ce..e404345 100644 --- a/wicket-user-guide/src/docs/guide/monitoring/monitoring_2.gdoc +++ b/wicket-user-guide/src/docs/guide/monitoring/monitoring_2.gdoc @@ -1,5 +1,6 @@ To visualize the metrics with Graphite a little additional configuration is required: + (1) Add the additional maven dependency to your project: {code} <dependency> @@ -11,15 +12,27 @@ To visualize the metrics with Graphite a little additional configuration is requ (2) Add the following code to your Application's init method: {code} -MetricRegistry metricRegistry = Application.get().getMetaData(WicketMetrics.METRIC_REGISTRY) -final Graphite graphite = new Graphite(new InetSocketAddress("127.0.0.1", 2003)); -final GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry) - .prefixedWith("WebApplications") - .convertRatesTo(TimeUnit.SECONDS) - .convertDurationsTo(TimeUnit.MILLISECONDS) - .filter(MetricFilter.ALL) - .build(graphite); -reporter.start(1, TimeUnit.SECONDS); + private GraphiteReporter reporter; + + @Override + protected void init() + { + MetricRegistry metricRegistry = this.getMetaData(WicketMetrics.METRIC_REGISTRY); + final Graphite graphite = new Graphite(new InetSocketAddress("127.0.0.1", 2003)); + reporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith("WebApplications") + .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS) + .filter(MetricFilter.ALL).build(graphite); + + // Collects data every 5 seconds + reporter.start(5, TimeUnit.SECONDS); + } + + @Override + protected void onDestroy() + { + super.onDestroy(); + reporter.stop(); + } {code} (3) Install and setup graphite on your system. Example installation for mac (beware that this is only a quickstart setup!):
