This is an automated email from the ASF dual-hosted git repository. sebawagner pushed a commit to branch feature/OPENMEETINGS-2567-investigate-performance-monitoring in repository https://gitbox.apache.org/repos/asf/openmeetings.git
commit a4db277481e195307e080140e64c172a0679b428 Author: Sebastian Wagner <sebawag...@apache.org> AuthorDate: Thu Feb 4 14:34:28 2021 +1300 OPENMEETINGS-2567 Enable annotation based AOP style attributes for Spring Managed beans. --- openmeetings-core/pom.xml | 9 ++++ .../openmeetings/core/remote/StreamProcessor.java | 2 + .../core/util/logging/PrometheusAspect.java | 50 ++++++++++++++++++++++ .../openmeetings/core/util/logging/Timed.java | 31 ++++++++++++++ .../web/util/logging/TomcatGenericExports.java | 19 ++++++++ .../webapp/WEB-INF/classes/applicationContext.xml | 3 ++ pom.xml | 11 +++++ 7 files changed, 125 insertions(+) diff --git a/openmeetings-core/pom.xml b/openmeetings-core/pom.xml index 217fa9e..8c59f0e 100644 --- a/openmeetings-core/pom.xml +++ b/openmeetings-core/pom.xml @@ -100,6 +100,15 @@ <version>${spring.version}</version> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjtools</artifactId> + <version>1.9.6</version> + </dependency> + <dependency> <groupId>org.kurento</groupId> <artifactId>kurento-client</artifactId> </dependency> diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java index be483e0..0355abe 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java @@ -38,6 +38,7 @@ import org.apache.openmeetings.core.converter.IRecordingConverter; import org.apache.openmeetings.core.converter.InterviewConverter; import org.apache.openmeetings.core.converter.RecordingConverter; import org.apache.openmeetings.core.util.WebSocketHelper; +import org.apache.openmeetings.core.util.logging.Timed; import org.apache.openmeetings.db.dao.record.RecordingDao; import org.apache.openmeetings.db.entity.basic.Client; import org.apache.openmeetings.db.entity.basic.Client.Activity; @@ -83,6 +84,7 @@ public class StreamProcessor implements IStreamProcessor { @Autowired private InterviewConverter interviewConverter; + @Timed void onMessage(Client c, final String cmdId, JSONObject msg) { final String uid = msg.optString("uid"); KStream sender; diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/PrometheusAspect.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/PrometheusAspect.java new file mode 100644 index 0000000..af4c97a --- /dev/null +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/PrometheusAspect.java @@ -0,0 +1,50 @@ +/* + + * 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.openmeetings.core.util.logging; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class PrometheusAspect { + + private static final Logger log = LoggerFactory.getLogger(PrometheusAspect.class); + + @Around("@annotation(Timed)") + public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { + final long start = System.currentTimeMillis(); + + final Object proceed = joinPoint.proceed(); + + final long executionTime = System.currentTimeMillis() - start; + + log.warn(joinPoint.getSignature() + " ################################# executed in " + executionTime + "ms"); + System.out.println( + joinPoint.getSignature() + " ################################# executed in " + executionTime + "ms"); + + return proceed; + } + +} diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/Timed.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/Timed.java new file mode 100644 index 0000000..2d7e648 --- /dev/null +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/logging/Timed.java @@ -0,0 +1,31 @@ +/* + + * 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.openmeetings.core.util.logging; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Timed { + +} diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/logging/TomcatGenericExports.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/logging/TomcatGenericExports.java index e910dc4..daf0d25 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/logging/TomcatGenericExports.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/logging/TomcatGenericExports.java @@ -11,6 +11,25 @@ import javax.management.*; import java.lang.management.ManagementFactory; import java.util.*; +/* + + * 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. + */ /** * Exports Tomcat metrics applicable to most most applications: * diff --git a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml index 211f0e1..64acb8d 100644 --- a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml +++ b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml @@ -22,10 +22,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" + xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" > <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> @@ -38,6 +40,7 @@ <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> <context:annotation-config /> + <aop:aspectj-autoproxy/> <context:component-scan base-package="org.apache.openmeetings" /> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" diff --git a/pom.xml b/pom.xml index 3770f02..9da8f6c 100644 --- a/pom.xml +++ b/pom.xml @@ -472,6 +472,17 @@ </exclusions> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>${spring.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> <groupId>org.mnode.ical4j</groupId> <artifactId>ical4j</artifactId> <version>${ical4j.version}</version>