Skip to content

Commit 6d2f749

Browse files
authored
add segment size metric on segment push (#8387)
Adds an offline segment size metric only when a new segment is pushed. this is stored as a gauge and based on table name. This is useful to build detectors in case: - someone tries to push a segment that is too large - your segments are organically growing in size and you want to know once you've hit a threshold
1 parent d1b7679 commit 6d2f749

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pinot-common/src/main/java/org/apache/pinot/common/metrics/ControllerGauge.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public enum ControllerGauge implements AbstractMetrics.Gauge {
6969
// Estimated size of offline table
7070
OFFLINE_TABLE_ESTIMATED_SIZE("OfflineTableEstimatedSize", false),
7171

72+
// Size of the last uploaded offline segment
73+
LAST_PUSHED_SEGMENT_SIZE("LastPushedSegmentSize", false),
74+
75+
7276
// Table quota based on setting in table config
7377
TABLE_QUOTA("TableQuotaBasedOnTableConfig", false),
7478

pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentUploadDownloadRestletResource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.apache.commons.io.IOUtils;
6262
import org.apache.commons.lang3.tuple.ImmutablePair;
6363
import org.apache.commons.lang3.tuple.Pair;
64+
import org.apache.pinot.common.metrics.ControllerGauge;
6465
import org.apache.pinot.common.metrics.ControllerMeter;
6566
import org.apache.pinot.common.metrics.ControllerMetrics;
6667
import org.apache.pinot.common.restlet.resources.StartReplaceSegmentsRequest;
@@ -304,6 +305,10 @@ private SuccessResponse uploadSegment(@Nullable String tableName, TableType tabl
304305
completeZkOperations(enableParallelPushProtection, headers, finalSegmentFile, tableNameWithType, segmentMetadata,
305306
segmentName, zkDownloadUri, moveSegmentToFinalLocation, crypterClassName, allowRefresh);
306307

308+
// We only set this gauge after the segment is successfully pushed.
309+
_controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.LAST_PUSHED_SEGMENT_SIZE,
310+
FileUtils.sizeOfDirectory(tempSegmentDir));
311+
307312
return new SuccessResponse("Successfully uploaded segment: " + segmentName + " of table: " + tableNameWithType);
308313
} catch (WebApplicationException e) {
309314
throw e;

0 commit comments

Comments
 (0)