aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSerhat Yenican <104850907+serhat-yenican-sonarsource@users.noreply.github.com>2025-03-19 12:36:57 +0100
committersonartech <sonartech@sonarsource.com>2025-03-19 20:03:10 +0000
commitf48a45e427da25c8a65decff94cbc2a86d569929 (patch)
treea95db9fba0f458a3d48c22b38f3d7836d575f18b /server
parent71d61816d5b209c49cb10c4b0e4e382195c0e22d (diff)
downloadsonarqube-f48a45e427da25c8a65decff94cbc2a86d569929.tar.gz
sonarqube-f48a45e427da25c8a65decff94cbc2a86d569929.zip
SONAR-24411 send fix suggestion telemetry for self-hosted llm providers
Diffstat (limited to 'server')
-rw-r--r--server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Dimension.java3
-rw-r--r--server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/schema/FixSuggestionMetric.java56
-rw-r--r--server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/DimensionTest.java2
-rw-r--r--server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/schema/FixSuggestionMetricTest.java51
4 files changed, 111 insertions, 1 deletions
diff --git a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Dimension.java b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Dimension.java
index f3479858bff..4b136272f6c 100644
--- a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Dimension.java
+++ b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/Dimension.java
@@ -31,7 +31,8 @@ public enum Dimension {
USER("user"),
PROJECT("project"),
LANGUAGE("language"),
- ANALYSIS("analysis");
+ ANALYSIS("analysis"),
+ FIX_SUGGESTION("fixsuggestion");
private final String value;
diff --git a/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/schema/FixSuggestionMetric.java b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/schema/FixSuggestionMetric.java
new file mode 100644
index 00000000000..e7b079a0b6d
--- /dev/null
+++ b/server/sonar-telemetry-core/src/main/java/org/sonar/telemetry/core/schema/FixSuggestionMetric.java
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2025 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.
+ */
+package org.sonar.telemetry.core.schema;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.sonar.telemetry.core.TelemetryDataType;
+
+import static org.sonar.telemetry.core.Granularity.ADHOC;
+
+public class FixSuggestionMetric extends InstallationMetric {
+
+ @JsonProperty("fix_suggestion_uuid")
+ private String fixSuggestionUuid;
+
+ @JsonProperty("project_uuid")
+ private String projectUuid;
+
+ public FixSuggestionMetric(String key, Object value, TelemetryDataType type, String projectUuid, String fixSuggestionUuid) {
+ super(key, value, type, ADHOC);
+ this.projectUuid = projectUuid;
+ this.fixSuggestionUuid = fixSuggestionUuid;
+ }
+
+ public String getProjectUuid() {
+ return projectUuid;
+ }
+
+ public void setProjectUuid(String projectUuid) {
+ this.projectUuid = projectUuid;
+ }
+
+ public String getFixSuggestionUuid() {
+ return fixSuggestionUuid;
+ }
+
+ public void setFixSuggestionUuid(String fixSuggestionUuid) {
+ this.fixSuggestionUuid = fixSuggestionUuid;
+ }
+}
diff --git a/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/DimensionTest.java b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/DimensionTest.java
index f80c2a971bb..69d77f3716f 100644
--- a/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/DimensionTest.java
+++ b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/DimensionTest.java
@@ -39,11 +39,13 @@ class DimensionTest {
assertEquals(Dimension.USER, Dimension.fromValue("user"));
assertEquals(Dimension.PROJECT, Dimension.fromValue("project"));
assertEquals(Dimension.LANGUAGE, Dimension.fromValue("language"));
+ assertEquals(Dimension.FIX_SUGGESTION, Dimension.fromValue("fixsuggestion"));
assertEquals(Dimension.INSTALLATION, Dimension.fromValue("INSTALLATION"));
assertEquals(Dimension.USER, Dimension.fromValue("USER"));
assertEquals(Dimension.PROJECT, Dimension.fromValue("PROJECT"));
assertEquals(Dimension.LANGUAGE, Dimension.fromValue("LANGUAGE"));
+ assertEquals(Dimension.FIX_SUGGESTION, Dimension.fromValue("FIXSUGGESTION"));
}
@Test
diff --git a/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/schema/FixSuggestionMetricTest.java b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/schema/FixSuggestionMetricTest.java
new file mode 100644
index 00000000000..7c5409dcc2f
--- /dev/null
+++ b/server/sonar-telemetry-core/src/test/java/org/sonar/telemetry/core/schema/FixSuggestionMetricTest.java
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2025 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.
+ */
+package org.sonar.telemetry.core.schema;
+
+import org.junit.jupiter.api.Test;
+import org.sonar.telemetry.core.Granularity;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.telemetry.core.TelemetryDataType.STRING;
+
+class FixSuggestionMetricTest {
+
+ @Test
+ void getters() {
+ FixSuggestionMetric metric = new FixSuggestionMetric("ai_codefix_suggestion_rule_key", "rule:key", STRING, "projectUuid", "fixSuggestionUuid");
+
+ assertThat(metric.getKey()).isEqualTo("ai_codefix_suggestion_rule_key");
+ assertThat(metric.getValue()).isEqualTo("rule:key");
+ assertThat(metric.getProjectUuid()).isEqualTo("projectUuid");
+ assertThat(metric.getGranularity()).isEqualTo(Granularity.ADHOC);
+ assertThat(metric.getType()).isEqualTo(STRING);
+ assertThat(metric.getFixSuggestionUuid()).isEqualTo("fixSuggestionUuid");
+ }
+
+ @Test
+ void setters() {
+ FixSuggestionMetric metric = new FixSuggestionMetric("ai_codefix_suggestion_rule_key", "rule:key", STRING, "projectUuid", "fixSuggestionUuid");
+ metric.setProjectUuid("newProjectUuid");
+ metric.setFixSuggestionUuid("newFixSuggestionUuid");
+
+ assertThat(metric.getProjectUuid()).isEqualTo("newProjectUuid");
+ assertThat(metric.getFixSuggestionUuid()).isEqualTo("newFixSuggestionUuid");
+ }
+}