Skip to content

Commit

Permalink
Fix segment/deleted/count metric not being emitted (#14433)
Browse files Browse the repository at this point in the history
* Fix segment/deleted/count metric

* Fix segment/deleted/count metric

* Fix segment/deleted/count metric
  • Loading branch information
maytasm committed Jun 15, 2023
1 parent 4935f24 commit 5d76d0e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/operations/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ private void emitStatsForHistoricalManagementDuties(DruidCluster cluster, Coordi
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,25 @@ public void testRunOnlyEmitStatsForHistoricalDuties()
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();
if ("segment/overShadowed/count".equals(metric)) {
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);
Assert.assertEquals(DruidCoordinator.HISTORICAL_MANAGEMENT_DUTIES_DUTY_GROUP, dutyGroup);
}
Assert.assertTrue(foundHistoricalDutyMetric);
Assert.assertFalse(foundCompactMetric);
Assert.assertTrue(foundSegmentDeletedCount);
}

@Test
Expand Down

0 comments on commit 5d76d0e

Please sign in to comment.