Skip to content

Commit bd860d8

Browse files
author
hongli.wwj
committed
[Blob] Add some metric when write blob from http.
1 parent 9ea8120 commit bd860d8

11 files changed

Lines changed: 611 additions & 6 deletions

File tree

docs/docs/maintenance/metrics.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Paimon has supported built-in metrics to measure operations of **commits**, **sc
3737

3838
## Metrics List
3939

40-
Below is lists of Paimon built-in metrics. They are summarized into types of scan metrics, commit metrics, write metrics, write buffer metrics and compaction metrics.
40+
Below is lists of Paimon built-in metrics. They are summarized into types of scan metrics, commit metrics, write metrics, write buffer metrics, blob fetch metrics and compaction metrics.
4141

4242
### Scan Metrics
4343

@@ -226,6 +226,85 @@ Below is lists of Paimon built-in metrics. They are summarized into types of sca
226226
</tbody>
227227
</table>
228228

229+
### Blob Fetch Metrics
230+
231+
<table class="table table-bordered">
232+
<thead>
233+
<tr>
234+
<th class="text-left" style="width: 225pt">Metrics Name</th>
235+
<th class="text-left" style="width: 70pt">Type</th>
236+
<th class="text-left" style="width: 300pt">Description</th>
237+
</tr>
238+
</thead>
239+
<tbody>
240+
<tr>
241+
<td>blobFetchTotal</td>
242+
<td>Counter</td>
243+
<td>Total number of blob fetch outcomes handled during write, including successful fetches, failures, and missing resources written as NULL.</td>
244+
</tr>
245+
<tr>
246+
<td>blobFetchSuccess</td>
247+
<td>Counter</td>
248+
<td>Total number of blob fetches that completed successfully.</td>
249+
</tr>
250+
<tr>
251+
<td>blobFetchSuccessBytes</td>
252+
<td>Counter</td>
253+
<td>Total bytes written by successful blob fetches.</td>
254+
</tr>
255+
<tr>
256+
<td>blobFetchNullWritten</td>
257+
<td>Counter</td>
258+
<td>Total number of NULL values written because a blob resource was missing or failed to fetch.</td>
259+
</tr>
260+
<tr>
261+
<td>blobFetchMissingFileNullWritten</td>
262+
<td>Counter</td>
263+
<td>Total number of NULL values written because <code>blob-write-null-on-missing-file</code> handled a missing blob resource.</td>
264+
</tr>
265+
<tr>
266+
<td>blobFetchFailureNullWritten</td>
267+
<td>Counter</td>
268+
<td>Total number of NULL values written because <code>blob-write-null-on-fetch-failure</code> handled a non-404 blob fetch failure.</td>
269+
</tr>
270+
<tr>
271+
<td>blobFetchFailure</td>
272+
<td>Counter</td>
273+
<td>Total number of blob fetch failures that were not written as NULL.</td>
274+
</tr>
275+
<tr>
276+
<td>blobFetchHttpNotFound</td>
277+
<td>Counter</td>
278+
<td>Total number of HTTP 404 blob fetch failures.</td>
279+
</tr>
280+
<tr>
281+
<td>blobFetchHttpClientError</td>
282+
<td>Counter</td>
283+
<td>Total number of non-404 HTTP 4xx blob fetch failures.</td>
284+
</tr>
285+
<tr>
286+
<td>blobFetchHttpServerError</td>
287+
<td>Counter</td>
288+
<td>Total number of HTTP 5xx blob fetch failures.</td>
289+
</tr>
290+
<tr>
291+
<td>blobFetchHttpOtherError</td>
292+
<td>Counter</td>
293+
<td>Total number of blob fetch failures with HTTP status codes outside 4xx and 5xx.</td>
294+
</tr>
295+
<tr>
296+
<td>blobFetchInvalidUri</td>
297+
<td>Counter</td>
298+
<td>Total number of blob fetch failures caused by invalid URIs.</td>
299+
</tr>
300+
<tr>
301+
<td>blobFetchOtherError</td>
302+
<td>Counter</td>
303+
<td>Total number of blob fetch failures that are not classified as HTTP status or invalid URI failures.</td>
304+
</tr>
305+
</tbody>
306+
</table>
307+
229308
### Compaction Metrics
230309

231310
<table class="table table-bordered">
@@ -375,6 +454,11 @@ From Flink Web-UI, go to the committer operator's metrics, it's shown as:
375454
<td>&lt;host&gt;.taskmanager.&lt;tm_id&gt;.&lt;job_name&gt;.&lt;writer_operator_name&gt;.&lt;subtask_index&gt;</td>
376455
<td>paimon.table.&lt;table_name&gt;.writeBuffer</td>
377456
</tr>
457+
<tr>
458+
<td>Blob Fetch Metrics</td>
459+
<td>&lt;host&gt;.taskmanager.&lt;tm_id&gt;.&lt;job_name&gt;.&lt;writer_operator_name&gt;.&lt;subtask_index&gt;</td>
460+
<td>paimon.table.&lt;table_name&gt;.blobFetch</td>
461+
</tr>
378462
<tr>
379463
<td>Compaction Metrics</td>
380464
<td>&lt;host&gt;.taskmanager.&lt;tm_id&gt;.&lt;job_name&gt;.&lt;writer_operator_name&gt;.&lt;subtask_index&gt;</td>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.paimon.data;
20+
21+
/** Reporter for blob fetch metrics. */
22+
public interface BlobFetchMetricReporter {
23+
24+
BlobFetchMetricReporter NOOP =
25+
new BlobFetchMetricReporter() {
26+
@Override
27+
public void recordSuccess(long bytes) {}
28+
29+
@Override
30+
public void recordMissingFileNullWritten(boolean httpNotFound) {}
31+
32+
@Override
33+
public void recordFetchFailureNullWritten(Throwable throwable) {}
34+
35+
@Override
36+
public void recordFetchFailure(Throwable throwable) {}
37+
};
38+
39+
void recordSuccess(long bytes);
40+
41+
void recordMissingFileNullWritten(boolean httpNotFound);
42+
43+
void recordFetchFailureNullWritten(Throwable throwable);
44+
45+
void recordFetchFailure(Throwable throwable);
46+
}

paimon-core/src/main/java/org/apache/paimon/append/DedicatedFormatRollingFileWriter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ public DedicatedFormatRollingFileWriter(
200200
context.blobConsumer(),
201201
context.blobInlineFields(),
202202
context.writeNullOnMissingFile(),
203-
context.writeNullOnFetchFailure());
203+
context.writeNullOnFetchFailure(),
204+
context.blobFetchMetricReporter());
204205
} else {
205206
this.blobWriterFactory = null;
206207
}

paimon-core/src/main/java/org/apache/paimon/append/MultipleBlobFileWriter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.paimon.append;
2020

2121
import org.apache.paimon.data.BlobConsumer;
22+
import org.apache.paimon.data.BlobFetchMetricReporter;
2223
import org.apache.paimon.data.InternalRow;
2324
import org.apache.paimon.fileindex.FileIndexOptions;
2425
import org.apache.paimon.format.blob.BlobFileFormat;
@@ -65,14 +66,16 @@ public MultipleBlobFileWriter(
6566
@Nullable BlobConsumer blobConsumer,
6667
Set<String> blobInlineFields,
6768
boolean writeNullOnMissingFile,
68-
boolean writeNullOnFetchFailure) {
69+
boolean writeNullOnFetchFailure,
70+
BlobFetchMetricReporter blobFetchMetricReporter) {
6971
RowType blobRowType = new RowType(fieldsInBlobFile(writeSchema, blobInlineFields));
7072
this.blobWriters = new ArrayList<>();
7173
for (String blobFieldName : blobRowType.getFieldNames()) {
7274
BlobFileFormat blobFileFormat = new BlobFileFormat();
7375
blobFileFormat.setWriteConsumer(blobConsumer);
7476
blobFileFormat.setWriteNullOnMissingFile(writeNullOnMissingFile);
7577
blobFileFormat.setWriteNullOnFetchFailure(writeNullOnFetchFailure);
78+
blobFileFormat.setBlobFetchMetricReporter(blobFetchMetricReporter);
7679
blobWriters.add(
7780
new BlobProjectedFileWriter(
7881
() ->

paimon-core/src/main/java/org/apache/paimon/operation/BaseAppendFileStoreWrite.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.apache.paimon.io.DataFileMeta;
3636
import org.apache.paimon.io.RowDataRollingFileWriter;
3737
import org.apache.paimon.manifest.FileSource;
38+
import org.apache.paimon.metrics.MetricRegistry;
39+
import org.apache.paimon.operation.metrics.BlobFetchMetrics;
3840
import org.apache.paimon.reader.RecordReaderIterator;
3941
import org.apache.paimon.statistics.SimpleColStatsCollector;
4042
import org.apache.paimon.types.RowType;
@@ -80,6 +82,7 @@ public abstract class BaseAppendFileStoreWrite extends MemoryFileStoreWrite<Inte
8082
private final RowType rowType;
8183

8284
private @Nullable BlobFileContext blobContext;
85+
private @Nullable BlobFetchMetrics blobFetchMetrics;
8386
private RowType writeType;
8487
private @Nullable List<String> writeCols;
8588
private boolean forceBufferSpill = false;
@@ -117,6 +120,16 @@ public BaseAppendFileStoreWrite withBlobConsumer(BlobConsumer blobConsumer) {
117120
return this;
118121
}
119122

123+
@Override
124+
public BaseAppendFileStoreWrite withMetricRegistry(MetricRegistry metricRegistry) {
125+
super.withMetricRegistry(metricRegistry);
126+
if (blobContext != null) {
127+
blobFetchMetrics = new BlobFetchMetrics(metricRegistry, tableName);
128+
blobContext = blobContext.withBlobFetchMetricReporter(blobFetchMetrics);
129+
}
130+
return this;
131+
}
132+
120133
@Override
121134
protected RecordWriter<InternalRow> createWriter(
122135
BinaryRow partition,
@@ -179,6 +192,14 @@ private SimpleColStatsCollector.Factory[] statsCollectors() {
179192
return createStatsFactories(options.statsMode(), options, writeType.getFieldNames());
180193
}
181194

195+
@Override
196+
public void close() throws Exception {
197+
super.close();
198+
if (blobFetchMetrics != null) {
199+
blobFetchMetrics.close();
200+
}
201+
}
202+
182203
protected abstract CompactManager getCompactManager(
183204
BinaryRow partition,
184205
int bucket,

paimon-core/src/main/java/org/apache/paimon/operation/BlobFileContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.paimon.CoreOptions;
2222
import org.apache.paimon.data.BlobConsumer;
23+
import org.apache.paimon.data.BlobFetchMetricReporter;
2324
import org.apache.paimon.types.DataField;
2425
import org.apache.paimon.types.DataTypeRoot;
2526
import org.apache.paimon.types.RowType;
@@ -39,6 +40,7 @@ public class BlobFileContext {
3940
private final boolean writeNullOnFetchFailure;
4041

4142
private @Nullable BlobConsumer blobConsumer;
43+
private BlobFetchMetricReporter blobFetchMetricReporter = BlobFetchMetricReporter.NOOP;
4244

4345
private BlobFileContext(
4446
Set<String> blobDescriptorFields,
@@ -81,6 +83,12 @@ public BlobFileContext withBlobConsumer(BlobConsumer blobConsumer) {
8183
return this;
8284
}
8385

86+
public BlobFileContext withBlobFetchMetricReporter(
87+
BlobFetchMetricReporter blobFetchMetricReporter) {
88+
this.blobFetchMetricReporter = blobFetchMetricReporter;
89+
return this;
90+
}
91+
8492
public BlobFileContext withWriteType(RowType writeType) {
8593
if (writeType.getFieldTypes().stream().noneMatch(t -> t.is(BLOB))) {
8694
return null;
@@ -108,4 +116,8 @@ public boolean writeNullOnMissingFile() {
108116
public boolean writeNullOnFetchFailure() {
109117
return writeNullOnFetchFailure;
110118
}
119+
120+
public BlobFetchMetricReporter blobFetchMetricReporter() {
121+
return blobFetchMetricReporter;
122+
}
111123
}

0 commit comments

Comments
 (0)