aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-pushapi
diff options
context:
space:
mode:
authorlukasz-jarocki-sonarsource <77498856+lukasz-jarocki-sonarsource@users.noreply.github.com>2022-02-03 10:35:15 +0100
committersonartech <sonartech@sonarsource.com>2022-02-18 15:48:03 +0000
commite04d2b354591a5e19fa6ae2e489abcd7f2712547 (patch)
tree7166e4f1d4f3e75772f7861ad3dfac5e096809d1 /server/sonar-webserver-pushapi
parent33901a8a3f5a484bacbf9bdd7d1f9f994c4a0bfd (diff)
downloadsonarqube-e04d2b354591a5e19fa6ae2e489abcd7f2712547.tar.gz
sonarqube-e04d2b354591a5e19fa6ae2e489abcd7f2712547.zip
Added monitoring and telemetry to SonarLint push feature. (#5315)
* SONAR-15921 add number of connected sonarlint clients to telemetry
Diffstat (limited to 'server/sonar-webserver-pushapi')
-rw-r--r--server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistry.java6
-rw-r--r--server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistryTest.java6
2 files changed, 5 insertions, 7 deletions
diff --git a/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistry.java b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistry.java
index 44d9fa4917d..b3319ddc579 100644
--- a/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistry.java
+++ b/server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistry.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.pushapi.sonarlint;
-import com.google.common.annotations.VisibleForTesting;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.servlet.AsyncEvent;
@@ -47,9 +46,8 @@ public class SonarLintClientsRegistry {
LOG.debug("Removing SonarLint client");
}
- @VisibleForTesting
- List<SonarLintClient> getAllClients() {
- return clients;
+ public long countConnectedClients() {
+ return clients.size();
}
class SonarLintClientEventsListener implements AsyncListener {
diff --git a/server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistryTest.java b/server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistryTest.java
index f6f0ccd68f7..a70886166ea 100644
--- a/server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistryTest.java
+++ b/server/sonar-webserver-pushapi/src/test/java/org/sonar/server/pushapi/sonarlint/SonarLintClientsRegistryTest.java
@@ -48,11 +48,11 @@ public class SonarLintClientsRegistryTest {
underTest.registerClient(sonarLintClient);
- assertThat(underTest.getAllClients()).hasSize(1);
+ assertThat(underTest.countConnectedClients()).isEqualTo(1);
underTest.unregisterClient(sonarLintClient);
- assertThat(underTest.getAllClients()).isEmpty();
+ assertThat(underTest.countConnectedClients()).isZero();
}
@Test
@@ -63,7 +63,7 @@ public class SonarLintClientsRegistryTest {
underTest.registerClient(sonarLintClient);
}
- assertThat(underTest.getAllClients()).hasSize(10);
+ assertThat(underTest.countConnectedClients()).isEqualTo(10);
}
}