From 34cf59a340ea31410cbb60019e6e445e9d8d2929 Mon Sep 17 00:00:00 2001 From: lukasz-jarocki-sonarsource Date: Mon, 15 Jul 2024 16:33:09 +0200 Subject: [PATCH] SONAR-22479 moved 'user_enabled' metric to sonar-telemetry --- .../user}/TelemetryUserEnabledProviderIT.java | 18 +++++++-------- .../user}/TelemetryUserEnabledProvider.java | 6 ++++- .../sonar/telemetry/user}/package-info.java | 2 +- .../TelemetryUserEnabledProviderTest.java | 5 +++- .../authentication/AuthenticationModule.java | 4 +--- .../sonar/server/telemetry/package-info.java | 23 ------------------- server/sonar-webserver-core/build.gradle | 1 - .../platformlevel/PlatformLevel4.java | 5 ++-- 8 files changed, 23 insertions(+), 41 deletions(-) rename server/{sonar-webserver-auth/src/it/java/org/sonar/server/telemetry => sonar-telemetry/src/it/java/org/sonar/telemetry/legacy/user}/TelemetryUserEnabledProviderIT.java (79%) rename server/{sonar-webserver-auth/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/user}/TelemetryUserEnabledProvider.java (91%) rename server/{sonar-server-common/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/user}/package-info.java (96%) rename server/{sonar-webserver-auth/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/user}/TelemetryUserEnabledProviderTest.java (90%) delete mode 100644 server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/package-info.java diff --git a/server/sonar-webserver-auth/src/it/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderIT.java b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/legacy/user/TelemetryUserEnabledProviderIT.java similarity index 79% rename from server/sonar-webserver-auth/src/it/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderIT.java rename to server/sonar-telemetry/src/it/java/org/sonar/telemetry/legacy/user/TelemetryUserEnabledProviderIT.java index 801835ef851..255ebefec23 100644 --- a/server/sonar-webserver-auth/src/it/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderIT.java +++ b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/legacy/user/TelemetryUserEnabledProviderIT.java @@ -17,17 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.telemetry; +package org.sonar.telemetry.legacy.user; import java.util.Map; +import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; +import org.sonar.telemetry.user.TelemetryUserEnabledProvider; class TelemetryUserEnabledProviderIT { @@ -48,7 +48,7 @@ class TelemetryUserEnabledProviderIT { void getUuidValues_whenNoUsersInDatabase_shouldReturnEmptyMap() { Map uuidValues = underTest.getUuidValues(); - assertThat(uuidValues).isEmpty(); + Assertions.assertThat(uuidValues).isEmpty(); } @Test @@ -59,9 +59,9 @@ class TelemetryUserEnabledProviderIT { Map uuidValues = underTest.getUuidValues(); - assertThat(uuidValues).hasSize(2); - assertThat(uuidValues.values().stream().filter(Boolean::booleanValue)).hasSize(1); - assertThat(uuidValues.values().stream().filter(b -> !b)).hasSize(1); + Assertions.assertThat(uuidValues).hasSize(2); + Assertions.assertThat(uuidValues.values().stream().filter(Boolean::booleanValue)).hasSize(1); + Assertions.assertThat(uuidValues.values().stream().filter(b -> !b)).hasSize(1); } @Test @@ -73,7 +73,7 @@ class TelemetryUserEnabledProviderIT { Map uuidValues = underTest.getUuidValues(); - assertThat(uuidValues).hasSize(10); - assertThat(uuidValues.values().stream().filter(Boolean::booleanValue)).hasSize(10); + Assertions.assertThat(uuidValues).hasSize(10); + Assertions.assertThat(uuidValues.values().stream().filter(Boolean::booleanValue)).hasSize(10); } } diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/TelemetryUserEnabledProvider.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/TelemetryUserEnabledProvider.java similarity index 91% rename from server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/TelemetryUserEnabledProvider.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/TelemetryUserEnabledProvider.java index adcf530d0ed..aa7d715d949 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/TelemetryUserEnabledProvider.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/TelemetryUserEnabledProvider.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.telemetry; +package org.sonar.telemetry.user; import java.util.HashMap; import java.util.List; @@ -26,6 +26,10 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserQuery; +import org.sonar.telemetry.Dimension; +import org.sonar.telemetry.Granularity; +import org.sonar.telemetry.TelemetryDataProvider; +import org.sonar.telemetry.TelemetryDataType; public class TelemetryUserEnabledProvider implements TelemetryDataProvider { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/package-info.java similarity index 96% rename from server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/package-info.java index a1adc893867..a8fd2a249b9 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/user/package-info.java @@ -18,6 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @ParametersAreNonnullByDefault -package org.sonar.server.telemetry; +package org.sonar.telemetry.user; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/user/TelemetryUserEnabledProviderTest.java similarity index 90% rename from server/sonar-webserver-auth/src/test/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/user/TelemetryUserEnabledProviderTest.java index 57c0a2de161..032065828ec 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/telemetry/TelemetryUserEnabledProviderTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/user/TelemetryUserEnabledProviderTest.java @@ -17,10 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.server.telemetry; +package org.sonar.telemetry.user; import org.junit.jupiter.api.Test; import org.sonar.db.DbClient; +import org.sonar.telemetry.Dimension; +import org.sonar.telemetry.Granularity; +import org.sonar.telemetry.TelemetryDataType; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/AuthenticationModule.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/AuthenticationModule.java index 23a470c9872..9e83675ebd4 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/AuthenticationModule.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/AuthenticationModule.java @@ -23,7 +23,6 @@ import org.sonar.core.platform.Module; import org.sonar.server.authentication.event.AuthenticationEventImpl; import org.sonar.server.authentication.purge.ExpiredSessionsCleaner; import org.sonar.server.authentication.purge.ExpiredSessionsCleanerExecutorServiceImpl; -import org.sonar.server.telemetry.TelemetryUserEnabledProvider; public class AuthenticationModule extends Module { @Override @@ -55,7 +54,6 @@ public class AuthenticationModule extends Module { ExpiredSessionsCleanerExecutorServiceImpl.class, UserLastConnectionDatesUpdaterImpl.class, UserRegistrarImpl.class, - UserSessionInitializer.class, - TelemetryUserEnabledProvider.class); + UserSessionInitializer.class); } } diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/package-info.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/package-info.java deleted file mode 100644 index a1adc893867..00000000000 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/telemetry/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.telemetry; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-core/build.gradle b/server/sonar-webserver-core/build.gradle index de12a259f89..ecdf1cac652 100644 --- a/server/sonar-webserver-core/build.gradle +++ b/server/sonar-webserver-core/build.gradle @@ -49,7 +49,6 @@ dependencies { api project(':sonar-markdown') api project(':sonar-plugin-api-impl') api project(':sonar-ws') - api project(':server:sonar-telemetry') implementation project(path: ':server:sonar-webserver-webapi') compileOnlyApi 'com.github.spotbugs:spotbugs-annotations' diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 00b667efed2..631e9f88854 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -210,7 +210,6 @@ import org.sonar.server.plugins.ws.PluginsWs; import org.sonar.server.plugins.ws.UninstallAction; import org.sonar.server.plugins.ws.UpdatesAction; import org.sonar.server.project.DefaultBranchNameResolver; -import org.sonar.server.project.ProjectCppAutoconfigTelemetryProvider; import org.sonar.server.project.ProjectQGChangeEventListener; import org.sonar.server.project.VisibilityService; import org.sonar.server.project.ws.ProjectsWsModule; @@ -290,6 +289,8 @@ import org.sonar.telemetry.legacy.TelemetryClient; import org.sonar.telemetry.legacy.TelemetryDaemon; import org.sonar.telemetry.legacy.TelemetryDataJsonWriter; import org.sonar.telemetry.legacy.TelemetryDataLoaderImpl; +import org.sonar.telemetry.project.ProjectCppAutoconfigTelemetryProvider; +import org.sonar.telemetry.user.TelemetryUserEnabledProvider; import static org.sonar.core.extension.CoreExtensionsInstaller.noAdditionalSideFilter; import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel4OrNone; @@ -671,7 +672,7 @@ public class PlatformLevel4 extends PlatformLevel { TelemetryVersionProvider.class, TelemetryNclocProvider.class, ProjectCppAutoconfigTelemetryProvider.class, - + TelemetryUserEnabledProvider.class, // monitoring ServerMonitoringMetrics.class, -- 2.39.5