Commit 8cd5160c authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Merge branch 'monitoring' into 'master'

Monitoring configuration

See merge request !42
parents 805679e6 43c5883b
......@@ -292,6 +292,11 @@
<artifactId>swagger-annotations</artifactId>
<version>1.5.12</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-annotation</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<build>
......@@ -382,11 +387,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
......
......@@ -17,6 +17,7 @@
*/
package de.thm.arsnova.services;
import com.codahale.metrics.annotation.Gauge;
import com.github.leleuj.ss.oauth.client.authentication.OAuthAuthenticationToken;
import de.thm.arsnova.dao.IDatabaseDao;
import de.thm.arsnova.entities.DbUser;
......@@ -50,6 +51,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriUtils;
import org.stagemonitor.core.metrics.MonitorGauges;
import javax.annotation.PreDestroy;
import javax.mail.MessagingException;
......@@ -65,6 +67,7 @@ import java.util.regex.Pattern;
* Performs all user related operations.
*/
@Service
@MonitorGauges
public class UserService implements IUserService {
private static final int LOGIN_TRY_RESET_DELAY_MS = 30 * 1000;
......@@ -325,6 +328,7 @@ public class UserService implements IUserService {
}
@Override
@Gauge
public int loggedInUsers() {
return user2session.size();
}
......
......@@ -17,6 +17,8 @@
*/
package de.thm.arsnova.socket;
import com.codahale.metrics.annotation.Metered;
import com.codahale.metrics.annotation.Timed;
import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketConfig;
......@@ -131,6 +133,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
server.addEventListener("setFeedback", Feedback.class, new DataListener<Feedback>() {
@Override
@Timed(name = "setFeedbackEvent.onData")
public void onData(final SocketIOClient client, final Feedback data, final AckRequest ackSender) {
final User u = userService.getUser2SocketId(client.getSessionId());
if (u == null) {
......@@ -154,6 +157,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
server.addEventListener("setSession", Session.class, new DataListener<Session>() {
@Override
@Timed(name = "setSessionEvent.onData")
public void onData(final SocketIOClient client, final Session session, final AckRequest ackSender) {
final User u = userService.getUser2SocketId(client.getSessionId());
if (null == u) {
......@@ -183,6 +187,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
de.thm.arsnova.entities.transport.InterposedQuestion.class,
new DataListener<de.thm.arsnova.entities.transport.InterposedQuestion>() {
@Override
@Timed(name = "readInterposedQuestionEvent.onData")
public void onData(
SocketIOClient client,
de.thm.arsnova.entities.transport.InterposedQuestion question,
......@@ -213,6 +218,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
LearningProgressOptions.class,
new DataListener<LearningProgressOptions>() {
@Override
@Timed(name = "setLearningProgressOptionsEvent.onData")
public void onData(SocketIOClient client, LearningProgressOptions progressOptions, AckRequest ack) {
final User user = userService.getUser2SocketId(client.getSessionId());
final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(progressOptions.getSessionKeyword(), user);
......@@ -226,11 +232,13 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
server.addConnectListener(new ConnectListener() {
@Override
@Timed
public void onConnect(final SocketIOClient client) { }
});
server.addDisconnectListener(new DisconnectListener() {
@Override
@Timed
public void onDisconnect(final SocketIOClient client) {
if (
userService == null
......@@ -500,6 +508,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
@Async
@Override
@Timed(name = "visit.NewAnswerEvent")
public void visit(NewAnswerEvent event) {
final String sessionKey = event.getSession().getKeyword();
this.reportAnswersToLecturerQuestionAvailable(event.getSession(), new Question(event.getQuestion()));
......@@ -518,6 +527,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
@Async
@Override
@Timed(name = "visit.DeleteAnswerEvent")
public void visit(DeleteAnswerEvent event) {
final String sessionKey = event.getSession().getKeyword();
this.reportAnswersToLecturerQuestionAvailable(event.getSession(), new Question(event.getQuestion()));
......@@ -528,6 +538,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
@Async
@Override
@Timed(name = "visit.PiRoundDelayedStartEvent")
public void visit(PiRoundDelayedStartEvent event) {
final String sessionKey = event.getSession().getKeyword();
broadcastInSession(sessionKey, "startDelayedPiRound", event.getPiRoundInformations());
......@@ -535,6 +546,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
@Async
@Override
@Timed(name = "visit.PiRoundEndEvent")
public void visit(PiRoundEndEvent event) {
final String sessionKey = event.getSession().getKeyword();
broadcastInSession(sessionKey, "endPiRound", event.getPiRoundEndInformations());
......@@ -542,6 +554,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
@Async
@Override
@Timed(name = "visit.PiRoundCancelEvent")
public void visit(PiRoundCancelEvent event) {
final String sessionKey = event.getSession().getKeyword();
broadcastInSession(sessionKey, "cancelPiRound", event.getQuestionId());
......
package org.stagemonitor.core.metrics;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* When a type is marked with this annotation, the creation of gauges with
* @{@link com.codahale.metrics.annotation.Gauge} is activated for that type.
*
* <pre><code>
* \@MonitorGauges
* public class Queue {
* \@Gauge(name = "queueSize")
* public int getQueueSize() {
* return queue.size;
* }
* }
* </code></pre>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface MonitorGauges {
}
......@@ -13,3 +13,5 @@ log4j.category.io.netty=INFO
log4j.category.io.netty.channel.DefaultChannelPipeline=WARN
log4j.category.net.sf.json=WARN
log4j.category.org.springframework=INFO
log4j.category.org.stagemonitor.core=OFF
log4j.category.org.stagemonitor.requestmonitor=OFF
stagemonitor.active=true
stagemonitor.applicationName=ARSnova Backend
stagemonitor.instrument.include=de.thm.arsnova.controller,de.thm.arsnova.services,de.thm.arsnova.socket
stagemonitor.reporting.interval.console=180
stagemonitor.web.monitorOnlyForwardedRequests=true
......@@ -24,6 +24,8 @@
<bean class="de.thm.arsnova.web.ResponseInterceptorHandler" />
</mvc:interceptors>
<bean id="requestMappingHandlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" primary="true"></bean>
<aop:aspectj-autoproxy />
<!-- Enables swgger ui-->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment