aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-monitoring
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2021-12-14 14:29:02 +0100
committersonartech <sonartech@sonarsource.com>2021-12-17 12:06:46 +0000
commit437b7fcd2357ada2f9b8968403f0cdcaba6d2390 (patch)
tree00c7d4c7727d4747134eb1fccbed10d63d6765c2 /server/sonar-webserver-monitoring
parent2b9481fb72aeeab20c59085f828e68596e3af733 (diff)
downloadsonarqube-437b7fcd2357ada2f9b8968403f0cdcaba6d2390.tar.gz
sonarqube-437b7fcd2357ada2f9b8968403f0cdcaba6d2390.zip
SONAR-15688 fixing typos for some of the metrics and including new metric about web uptime
Diffstat (limited to 'server/sonar-webserver-monitoring')
-rw-r--r--server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java4
-rw-r--r--server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java25
2 files changed, 23 insertions, 6 deletions
diff --git a/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java b/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
index 82ed9dbd60a..db0afbd2a6a 100644
--- a/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
+++ b/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
@@ -79,12 +79,12 @@ public class ServerMonitoringMetrics {
.register();
computeEngineGauge = Gauge.build()
- .name("sonarqube_heath_compute_engine_status")
+ .name("sonarqube_health_compute_engine_status")
.help("Tells whether Compute Engine is up (healthy, ready to take tasks) or down. 1 for up, 0 for down")
.register();
elasticsearchGauge = Gauge.build()
- .name("sonarqube_heath_elasticsearch_status")
+ .name("sonarqube_health_elasticsearch_status")
.help("Tells whether Elasticsearch is up or down. 1 for Up, 0 for down")
.register();
diff --git a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
index 6d862b09dd1..3db9504b4f7 100644
--- a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
+++ b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
@@ -60,8 +60,8 @@ public class ServerMonitoringMetricsTest {
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_gitlab_status")).isPositive();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_bitbucket_status")).isPositive();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_azuredevops_status")).isPositive();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_compute_engine_status")).isPositive();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_elasticsearch_status")).isPositive();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_compute_engine_status")).isPositive();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_elasticsearch_status")).isPositive();
}
@Test
@@ -79,8 +79,8 @@ public class ServerMonitoringMetricsTest {
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_gitlab_status")).isZero();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_bitbucket_status")).isZero();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_azuredevops_status")).isZero();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_compute_engine_status")).isZero();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_elasticsearch_status")).isZero();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_compute_engine_status")).isZero();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_elasticsearch_status")).isZero();
}
@Test
@@ -120,6 +120,23 @@ public class ServerMonitoringMetricsTest {
}
@Test
+ public void setters_setElasticsearchMetricsWithLabels() {
+ ServerMonitoringMetrics metrics = new ServerMonitoringMetrics();
+ String[] labelNames = {"node_name"};
+ String[] labelValues = {"node_1"};
+
+ metrics.setElasticSearchDiskSpaceFreeBytes(labelValues[0], 30);
+ metrics.setElasticSearchDiskSpaceTotalBytes(labelValues[0], 30);
+
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_elasticsearch_disk_space_total_bytes",
+ labelNames, labelValues))
+ .isEqualTo(30);
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_elasticsearch_disk_space_free_bytes",
+ labelNames, labelValues))
+ .isEqualTo(30);
+ }
+
+ @Test
public void observeComputeEngineTaskDurationTest() {
ServerMonitoringMetrics metrics = new ServerMonitoringMetrics();
String[] labelNames = {"task_type", "project_key"};