Fix segment/deleted/count metric not being emitted (#14433)

* Fix segment/deleted/count metric

* Fix segment/deleted/count metric

* Fix segment/deleted/count metric
This commit is contained in:
Maytas Monsereenusorn 2023-06-15 14:08:19 -07:00 committed by GitHub
parent 4935f2470a
commit 5d76d0ea74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -283,7 +283,7 @@ These metrics are for the Druid Coordinator and are reset each time the Coordina
|`segment/moved/count`|Number of segments moved in the cluster.|`tier`|Varies|
|`segment/unmoved/count`|Number of segments which were chosen for balancing but were found to be already optimally placed.|`tier`|Varies|
|`segment/dropped/count`|Number of segments chosen to be dropped from the cluster due to being over-replicated.|`tier`|Varies|
|`segment/deleted/count`|Number of segments marked as unused due to drop rules.|`tier`|Varies|
|`segment/deleted/count`|Number of segments marked as unused due to drop rules.| |Varies|
|`segment/unneeded/count`|Number of segments dropped due to being marked as unused.|`tier`|Varies|
|`segment/cost/raw`|Used in cost balancing. The raw cost of hosting segments.|`tier`|Varies|
|`segment/cost/normalization`|Used in cost balancing. The normalization of hosting segments.|`tier`|Varies|

View File

@ -190,7 +190,13 @@ public class EmitClusterStatsAndMetrics implements CoordinatorDuty
emitTieredStats(emitter, "segment/moved/count", stats, "movedCount");
emitTieredStats(emitter, "segment/unmoved/count", stats, "unmovedCount");
emitTieredStats(emitter, "segment/deleted/count", stats, "deletedCount");
emitter.emit(
new ServiceMetricEvent.Builder()
.build(
"segment/deleted/count",
stats.getGlobalStat("deletedCount")
)
);
stats.forEachTieredStat(
"normalizedInitialCostTimesOneThousand",

View File

@ -71,6 +71,7 @@ public class EmitClusterStatsAndMetricsTest
List<ServiceEventBuilder> emittedEvents = argumentCaptor.getAllValues();
boolean foundCompactMetric = false;
boolean foundHistoricalDutyMetric = false;
boolean foundSegmentDeletedCount = false;
for (ServiceEventBuilder eventBuilder : emittedEvents) {
ServiceMetricEvent serviceMetricEvent = ((ServiceMetricEvent) eventBuilder.build("x", "x"));
String metric = serviceMetricEvent.getMetric();
@ -78,6 +79,9 @@ public class EmitClusterStatsAndMetricsTest
foundHistoricalDutyMetric = true;
} else if ("compact/task/count".equals(metric)) {
foundCompactMetric = true;
} else if ("segment/deleted/count".equals(metric)) {
foundSegmentDeletedCount = true;
continue;
}
String dutyGroup = (String) serviceMetricEvent.getUserDims().get("dutyGroup");
Assert.assertNotNull(dutyGroup);
@ -85,6 +89,7 @@ public class EmitClusterStatsAndMetricsTest
}
Assert.assertTrue(foundHistoricalDutyMetric);
Assert.assertFalse(foundCompactMetric);
Assert.assertTrue(foundSegmentDeletedCount);
}
@Test