diff options
author | Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> | 2024-03-27 11:08:42 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-03-27 20:02:41 +0000 |
commit | 600f05786a0d75aa14a956630c5a4ac68fdf2aa4 (patch) | |
tree | 0aeee226068bc0dfa18827b8e5bfe805f41a5828 /server/sonar-server-common | |
parent | 98e79991645ea8b0c6ac9b61a546814b46c10750 (diff) | |
download | sonarqube-600f05786a0d75aa14a956630c5a4ac68fdf2aa4.tar.gz sonarqube-600f05786a0d75aa14a956630c5a4ac68fdf2aa4.zip |
SONAR-21818 Add information if project is part of a monorepo to telemetry.
Diffstat (limited to 'server/sonar-server-common')
3 files changed, 30 insertions, 16 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java index 096f6d7f633..33c2739d23d 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java @@ -27,7 +27,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; -import org.sonar.core.platform.EditionProvider; import org.sonar.core.platform.EditionProvider.Edition; import org.sonar.db.project.CreationMethod; import org.sonar.db.user.UserTelemetryDto; @@ -42,7 +41,7 @@ public class TelemetryData { private final Long messageSequenceNumber; private final Map<String, String> plugins; private final Database database; - private final EditionProvider.Edition edition; + private final Edition edition; private final String defaultQualityGate; private final String sonarWayQualityGate; private final Long installationDate; @@ -109,7 +108,7 @@ public class TelemetryData { return database; } - public Optional<EditionProvider.Edition> getEdition() { + public Optional<Edition> getEdition() { return Optional.ofNullable(edition); } @@ -325,7 +324,6 @@ public class TelemetryData { return this; } - Builder setQualityProfiles(List<QualityProfile> qualityProfiles) { this.qualityProfiles = qualityProfiles; return this; @@ -378,18 +376,17 @@ public class TelemetryData { } public record QualityProfile(String uuid, @Nullable String parentUuid, String language, boolean isDefault, - boolean isBuiltIn, - @Nullable Boolean builtInParent, @Nullable Integer rulesOverriddenCount, - @Nullable Integer rulesActivatedCount, @Nullable Integer rulesDeactivatedCount - ) { + boolean isBuiltIn, + @Nullable Boolean builtInParent, @Nullable Integer rulesOverriddenCount, + @Nullable Integer rulesActivatedCount, @Nullable Integer rulesDeactivatedCount) { } record ManagedInstanceInformation(boolean isManaged, @Nullable String provider) { } record CloudUsage(boolean kubernetes, @Nullable String kubernetesVersion, @Nullable String kubernetesPlatform, - @Nullable String kubernetesProvider, - @Nullable String officialHelmChart, @Nullable String containerRuntime, boolean officialImage) { + @Nullable String kubernetesProvider, + @Nullable String officialHelmChart, @Nullable String containerRuntime, boolean officialImage) { } public static class ProjectStatistics { @@ -407,8 +404,8 @@ public class TelemetryData { private final Long developmentCost; private final int ncdId; private final Long externalSecurityReportExportedAt; - private final CreationMethod creationMethod; + private final Boolean monorepo; ProjectStatistics(Builder builder) { this.projectUuid = builder.projectUuid; @@ -426,6 +423,7 @@ public class TelemetryData { this.ncdId = builder.ncdId; this.externalSecurityReportExportedAt = builder.externalSecurityReportExportedAt; this.creationMethod = builder.creationMethod; + this.monorepo = builder.monorepo; } public int getNcdId() { @@ -488,6 +486,10 @@ public class TelemetryData { return creationMethod; } + public Boolean isMonorepo() { + return monorepo; + } + static class Builder { private String projectUuid; private Long branchCount; @@ -504,6 +506,7 @@ public class TelemetryData { private int ncdId; private Long externalSecurityReportExportedAt; private CreationMethod creationMethod; + private Boolean monorepo; public Builder setProjectUuid(String projectUuid) { this.projectUuid = projectUuid; @@ -580,6 +583,11 @@ public class TelemetryData { return this; } + public Builder setMonorepo(Boolean monorepo) { + this.monorepo = monorepo; + return this; + } + public ProjectStatistics build() { return new ProjectStatistics(this); } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java index 517a509ea5f..005c200b76f 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java @@ -203,6 +203,7 @@ public class TelemetryDataJsonWriter { json.prop("devopsPlatform", project.getDevopsPlatform()); json.prop(NCD_ID, project.getNcdId()); json.prop("project_creation_method", project.getCreationMethod().name()); + json.prop("monorepo", project.isMonorepo()); project.getBugs().ifPresent(bugs -> json.prop("bugs", bugs)); project.getVulnerabilities().ifPresent(vulnerabilities -> json.prop("vulnerabilities", vulnerabilities)); project.getSecurityHotspots().ifPresent(securityHotspots -> json.prop("securityHotspots", securityHotspots)); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java index afddb67daa4..f6582601ef0 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java @@ -463,7 +463,8 @@ public class TelemetryDataJsonWriterTest { "developmentCost": 30, "ncdId": 12345, "externalSecurityReportExportedAt": 1500000, - "project_creation_method": "LOCAL_API" + "project_creation_method": "LOCAL_API", + "monorepo": true }, { "projectUuid": "uuid-1", @@ -480,7 +481,8 @@ public class TelemetryDataJsonWriterTest { "developmentCost": 60, "ncdId": 12345, "externalSecurityReportExportedAt": 1500001, - "project_creation_method": "LOCAL_API" + "project_creation_method": "LOCAL_API", + "monorepo": false }, { "projectUuid": "uuid-2", @@ -497,7 +499,8 @@ public class TelemetryDataJsonWriterTest { "developmentCost": 90, "ncdId": 12345, "externalSecurityReportExportedAt": 1500002, - "project_creation_method": "LOCAL_API" + "project_creation_method": "LOCAL_API", + "monorepo": true } ] } @@ -730,7 +733,8 @@ public class TelemetryDataJsonWriterTest { .setScm("scm-" + i) .setDevops("devops-" + i) .setNcdId(NCD_ID) - .setCreationMethod(CreationMethod.LOCAL_API); + .setCreationMethod(CreationMethod.LOCAL_API) + .setMonorepo(false); } private static TelemetryData.ProjectStatistics.Builder getProjectStatisticsWithMetricBuilder(int i) { @@ -741,7 +745,8 @@ public class TelemetryDataJsonWriterTest { .setDevelopmentCost((i + 1L) * 30d) .setTechnicalDebt((i + 1L) * 60d) .setExternalSecurityReportExportedAt(1_500_000L + i) - .setCreationMethod(CreationMethod.LOCAL_API); + .setCreationMethod(CreationMethod.LOCAL_API) + .setMonorepo(i % 2 == 0); } private List<TelemetryData.QualityGate> attachQualityGates() { |