forked from apache/paimon
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d010f2d
commit c825b34
Showing
9 changed files
with
397 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
paimon-core/src/main/java/org/apache/paimon/operation/metrics/ScanMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.paimon.operation.metrics; | ||
|
||
import org.apache.paimon.annotation.VisibleForTesting; | ||
import org.apache.paimon.metrics.Histogram; | ||
import org.apache.paimon.metrics.MetricGroup; | ||
import org.apache.paimon.metrics.MetricRegistry; | ||
|
||
/** Metrics to measure scan operation. */ | ||
public class ScanMetrics { | ||
private static final int HISTOGRAM_WINDOW_SIZE = 10_000; | ||
@VisibleForTesting protected static final String GROUP_NAME = "scan"; | ||
private final MetricGroup metricGroup; | ||
|
||
public ScanMetrics(MetricRegistry registry, String tableName) { | ||
this.metricGroup = registry.tableMetricGroup(GROUP_NAME, tableName); | ||
registerGenericScanMetrics(); | ||
} | ||
|
||
@VisibleForTesting | ||
public MetricGroup getMetricGroup() { | ||
return metricGroup; | ||
} | ||
|
||
private Histogram durationHistogram; | ||
|
||
private ScanStats latestScan; | ||
|
||
@VisibleForTesting static final String LAST_SCAN_DURATION = "lastScanDuration"; | ||
@VisibleForTesting static final String SCAN_DURATION = "scanDuration"; | ||
@VisibleForTesting static final String LAST_SCANNED_MANIFESTS = "lastScannedManifests"; | ||
|
||
@VisibleForTesting | ||
static final String LAST_SKIPPED_BY_PARTITION_AND_STATS = "lastSkippedByPartitionAndStats"; | ||
|
||
@VisibleForTesting | ||
static final String LAST_SKIPPED_BY_BUCKET_AND_LEVEL_FILTER = | ||
"lastSkippedByBucketAndLevelFilter"; | ||
|
||
@VisibleForTesting | ||
static final String LAST_SKIPPED_BY_WHOLE_BUCKET_FILES_FILTER = | ||
"lastSkippedByWholeBucketFilesFilter"; | ||
|
||
@VisibleForTesting | ||
static final String LAST_SCAN_SKIPPED_TABLE_FILES = "lastScanSkippedTableFiles"; | ||
|
||
@VisibleForTesting | ||
static final String LAST_SCAN_RESULTED_TABLE_FILES = "lastScanResultedTableFiles"; | ||
|
||
private void registerGenericScanMetrics() { | ||
metricGroup.gauge( | ||
LAST_SCAN_DURATION, () -> latestScan == null ? 0L : latestScan.getDuration()); | ||
durationHistogram = metricGroup.histogram(SCAN_DURATION, HISTOGRAM_WINDOW_SIZE); | ||
metricGroup.gauge( | ||
LAST_SCANNED_MANIFESTS, | ||
() -> latestScan == null ? 0L : latestScan.getScannedManifests()); | ||
metricGroup.gauge( | ||
LAST_SKIPPED_BY_PARTITION_AND_STATS, | ||
() -> latestScan == null ? 0L : latestScan.getSkippedByPartitionAndStats()); | ||
metricGroup.gauge( | ||
LAST_SKIPPED_BY_BUCKET_AND_LEVEL_FILTER, | ||
() -> latestScan == null ? 0L : latestScan.getSkippedByBucketAndLevelFilter()); | ||
metricGroup.gauge( | ||
LAST_SKIPPED_BY_WHOLE_BUCKET_FILES_FILTER, | ||
() -> latestScan == null ? 0L : latestScan.getSkippedByWholeBucketFiles()); | ||
metricGroup.gauge( | ||
LAST_SCAN_SKIPPED_TABLE_FILES, | ||
() -> latestScan == null ? 0L : latestScan.getSkippedTableFiles()); | ||
metricGroup.gauge( | ||
LAST_SCAN_RESULTED_TABLE_FILES, | ||
() -> latestScan == null ? 0L : latestScan.getResultedTableFiles()); | ||
} | ||
|
||
public void reportScan(ScanStats scanStats) { | ||
latestScan = scanStats; | ||
durationHistogram.update(scanStats.getDuration()); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
paimon-core/src/main/java/org/apache/paimon/operation/metrics/ScanStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.paimon.operation.metrics; | ||
|
||
import org.apache.paimon.annotation.VisibleForTesting; | ||
|
||
/** Statistics for a scan operation. */ | ||
public class ScanStats { | ||
private final long duration; | ||
private final long scannedManifests; | ||
private final long skippedByPartitionAndStats; | ||
private final long skippedByBucketAndLevelFilter; | ||
|
||
private final long skippedByWholeBucketFiles; | ||
private final long skippedTableFiles; | ||
private final long resultedTableFiles; | ||
|
||
public ScanStats( | ||
long duration, | ||
long scannedManifests, | ||
long skippedByPartitionAndStats, | ||
long skippedByBucketAndLevelFilter, | ||
long skippedByWholeBucketFiles, | ||
long resultedTableFiles) { | ||
this.duration = duration; | ||
this.scannedManifests = scannedManifests; | ||
this.skippedByPartitionAndStats = skippedByPartitionAndStats; | ||
this.skippedByBucketAndLevelFilter = skippedByBucketAndLevelFilter; | ||
this.skippedByWholeBucketFiles = skippedByWholeBucketFiles; | ||
this.skippedTableFiles = | ||
skippedByPartitionAndStats | ||
+ skippedByBucketAndLevelFilter | ||
+ skippedByWholeBucketFiles; | ||
this.resultedTableFiles = resultedTableFiles; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getScannedManifests() { | ||
return scannedManifests; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getSkippedTableFiles() { | ||
return skippedTableFiles; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getResultedTableFiles() { | ||
return resultedTableFiles; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getSkippedByPartitionAndStats() { | ||
return skippedByPartitionAndStats; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getSkippedByBucketAndLevelFilter() { | ||
return skippedByBucketAndLevelFilter; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getSkippedByWholeBucketFiles() { | ||
return skippedByWholeBucketFiles; | ||
} | ||
|
||
@VisibleForTesting | ||
protected long getDuration() { | ||
return duration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.