Skip to content

Commit 98ee412

Browse files
Finalize IcebergMetricsReporter implementation
1 parent b7a4b5d commit 98ee412

File tree

2 files changed

+247
-157
lines changed

2 files changed

+247
-157
lines changed
Lines changed: 124 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.instrumentation.iceberg.v1_8;
27

38
import io.opentelemetry.api.metrics.LongCounter;
@@ -16,9 +21,11 @@ final class CommitMetricsBuilder {
1621
private static final String ADDED_EQ_DELETE_FILES = ROOT + ".added.equality_delete_files.count";
1722
private static final String ADDED_POS_DELETE_FILES = ROOT + ".added.position_delete_files.count";
1823
private static final String ADDED_DVS = ROOT + ".added.dvs.count";
19-
private static final String REMOVED_POS_DELETE_FILES = ROOT + ".removed.positional_delete_files.count";
24+
private static final String REMOVED_POS_DELETE_FILES =
25+
ROOT + ".removed.positional_delete_files.count";
2026
private static final String REMOVED_DVS = ROOT + ".removed.dvs.count";
21-
private static final String REMOVED_EQ_DELETE_FILES = ROOT + ".removed.equality_delete_files.count";
27+
private static final String REMOVED_EQ_DELETE_FILES =
28+
ROOT + ".removed.equality_delete_files.count";
2229
private static final String REMOVED_DELETE_FILES = ROOT + ".removed.delete_files.count";
2330
private static final String TOTAL_DELETE_FILES = ROOT + ".total.delete_files.count";
2431
private static final String ADDED_RECORDS = ROOT + ".added.records.count";
@@ -33,253 +40,227 @@ final class CommitMetricsBuilder {
3340
private static final String ADDED_EQ_DELETES = ROOT + ".added.equality_deletes.count";
3441
private static final String REMOVED_EQ_DELETES = ROOT + ".removed.equality_deletes.count";
3542
private static final String TOTAL_EQ_DELETES = ROOT + ".total.equality_deletes.count";
36-
private static final String KEPT_MANIFESTS_COUNT = ROOT + ".manifests_kept.count";
37-
private static final String CREATED_MANIFESTS_COUNT = ROOT + ".manifests_created.count";
38-
private static final String REPLACED_MANIFESTS_COUNT = ROOT + ".manifests_replaced.count";
39-
private static final String PROCESSED_MANIFEST_ENTRY_COUNT = ROOT + ".manifest_entries_processed.count";
4043

4144
private CommitMetricsBuilder() {
4245
// prevents instantiation
4346
}
4447

4548
static LongGauge duration(Meter meter) {
4649
return meter
47-
.gaugeBuilder(DURATION)
48-
.setDescription("The duration taken to process the commit.")
49-
.setUnit("ms")
50-
.ofLongs()
51-
.build();
50+
.gaugeBuilder(DURATION)
51+
.setDescription("The duration taken to process the commit.")
52+
.setUnit("ms")
53+
.ofLongs()
54+
.build();
5255
}
5356

5457
static LongCounter attempts(Meter meter) {
5558
return meter
56-
.counterBuilder(ATTEMPTS)
57-
.setDescription("The number of attempts made to complete this commit.")
58-
.setUnit("{attempt}")
59-
.build();
59+
.counterBuilder(ATTEMPTS)
60+
.setDescription("The number of attempts made to complete this commit.")
61+
.setUnit("{attempt}")
62+
.build();
6063
}
6164

6265
static LongCounter addedDataFiles(Meter meter) {
6366
return meter
64-
.counterBuilder(ADDED_DATA_FILES)
65-
.setDescription("The number of data files added as part of the commit.")
66-
.setUnit("{file}")
67-
.build();
67+
.counterBuilder(ADDED_DATA_FILES)
68+
.setDescription("The number of data files added as part of the commit.")
69+
.setUnit("{file}")
70+
.build();
6871
}
6972

7073
static LongCounter removedDataFiles(Meter meter) {
7174
return meter
72-
.counterBuilder(REMOVED_DATA_FILES)
73-
.setDescription("The number of data files removed as part of the commit.")
74-
.setUnit("{file}")
75-
.build();
75+
.counterBuilder(REMOVED_DATA_FILES)
76+
.setDescription("The number of data files removed as part of the commit.")
77+
.setUnit("{file}")
78+
.build();
7679
}
7780

7881
static LongCounter totalDataFiles(Meter meter) {
7982
return meter
80-
.counterBuilder(TOTAL_DATA_FILES)
81-
.setDescription("The number of data files added or removed as part of the commit.")
82-
.setUnit("{file}")
83-
.build();
83+
.counterBuilder(TOTAL_DATA_FILES)
84+
.setDescription("The number of data files added or removed as part of the commit.")
85+
.setUnit("{file}")
86+
.build();
8487
}
8588

8689
static LongCounter addedDeleteFiles(Meter meter) {
8790
return meter
88-
.counterBuilder(ADDED_DELETE_FILES)
89-
.setDescription("The overall number of delete files added as part of the commit.")
90-
.setUnit("{file}")
91-
.build();
91+
.counterBuilder(ADDED_DELETE_FILES)
92+
.setDescription("The overall number of delete files added as part of the commit.")
93+
.setUnit("{file}")
94+
.build();
9295
}
9396

9497
static LongCounter addedEqualityDeleteFiles(Meter meter) {
9598
return meter
96-
.counterBuilder(ADDED_EQ_DELETE_FILES)
97-
.setDescription("The number of equality delete files added as part of the commit.")
98-
.setUnit("{file}")
99-
.build();
99+
.counterBuilder(ADDED_EQ_DELETE_FILES)
100+
.setDescription("The number of equality delete files added as part of the commit.")
101+
.setUnit("{file}")
102+
.build();
100103
}
101104

102105
static LongCounter addedPositionDeleteFiles(Meter meter) {
103106
return meter
104-
.counterBuilder(ADDED_POS_DELETE_FILES)
105-
.setDescription("The number of position delete files added as part of the commit.")
106-
.setUnit("{file}")
107-
.build();
107+
.counterBuilder(ADDED_POS_DELETE_FILES)
108+
.setDescription("The number of position delete files added as part of the commit.")
109+
.setUnit("{file}")
110+
.build();
108111
}
109112

110113
static LongCounter addedDeletionVectors(Meter meter) {
111114
return meter
112-
.counterBuilder(ADDED_DVS)
113-
.setDescription("The number of deletion vector files added as part of the commit.")
114-
.setUnit("{file}")
115-
.build();
115+
.counterBuilder(ADDED_DVS)
116+
.setDescription("The number of deletion vector files added as part of the commit.")
117+
.setUnit("{file}")
118+
.build();
116119
}
117120

118121
static LongCounter removedPositionDeleteFiles(Meter meter) {
119122
return meter
120-
.counterBuilder(REMOVED_POS_DELETE_FILES)
121-
.setDescription("The number of position delete files removed as part of the commit.")
122-
.setUnit("{file}")
123-
.build();
123+
.counterBuilder(REMOVED_POS_DELETE_FILES)
124+
.setDescription("The number of position delete files removed as part of the commit.")
125+
.setUnit("{file}")
126+
.build();
124127
}
125128

126129
static LongCounter removedDeletionVectors(Meter meter) {
127130
return meter
128-
.counterBuilder(REMOVED_DVS)
129-
.setDescription("The number of deletion vector files removed as part of the commit.")
130-
.setUnit("{file}")
131-
.build();
131+
.counterBuilder(REMOVED_DVS)
132+
.setDescription("The number of deletion vector files removed as part of the commit.")
133+
.setUnit("{file}")
134+
.build();
132135
}
133136

134137
static LongCounter removedEqualityDeleteFiles(Meter meter) {
135138
return meter
136-
.counterBuilder(REMOVED_EQ_DELETE_FILES)
137-
.setDescription("The number of equality delete files removed as part of the commit.")
138-
.setUnit("{file}")
139-
.build();
139+
.counterBuilder(REMOVED_EQ_DELETE_FILES)
140+
.setDescription("The number of equality delete files removed as part of the commit.")
141+
.setUnit("{file}")
142+
.build();
140143
}
141144

142145
static LongCounter removedDeleteFiles(Meter meter) {
143146
return meter
144-
.counterBuilder(REMOVED_DELETE_FILES)
145-
.setDescription("The overall number of delete files removed as part of the commit.")
146-
.setUnit("{file}")
147-
.build();
147+
.counterBuilder(REMOVED_DELETE_FILES)
148+
.setDescription("The overall number of delete files removed as part of the commit.")
149+
.setUnit("{file}")
150+
.build();
148151
}
149152

150153
static LongCounter totalDeleteFiles(Meter meter) {
151154
return meter
152-
.counterBuilder(TOTAL_DELETE_FILES)
153-
.setDescription("The overall number of delete files added or removed as part of the commit.")
154-
.setUnit("{file}")
155-
.build();
155+
.counterBuilder(TOTAL_DELETE_FILES)
156+
.setDescription(
157+
"The overall number of delete files added or removed as part of the commit.")
158+
.setUnit("{file}")
159+
.build();
156160
}
157161

158162
static LongCounter addedRecords(Meter meter) {
159163
return meter
160-
.counterBuilder(ADDED_RECORDS)
161-
.setDescription("The number of records added as part of the commit.")
162-
.setUnit("{record}")
163-
.build();
164+
.counterBuilder(ADDED_RECORDS)
165+
.setDescription("The number of records added as part of the commit.")
166+
.setUnit("{record}")
167+
.build();
164168
}
165169

166170
static LongCounter removedRecords(Meter meter) {
167171
return meter
168-
.counterBuilder(REMOVED_RECORDS)
169-
.setDescription("The number of records removed as part of the commit.")
170-
.setUnit("{record}")
171-
.build();
172+
.counterBuilder(REMOVED_RECORDS)
173+
.setDescription("The number of records removed as part of the commit.")
174+
.setUnit("{record}")
175+
.build();
172176
}
173177

174178
static LongCounter totalRecords(Meter meter) {
175179
return meter
176-
.counterBuilder(TOTAL_RECORDS)
177-
.setDescription("The overall number of records added or removed as part of the commit.")
178-
.setUnit("{record}")
179-
.build();
180+
.counterBuilder(TOTAL_RECORDS)
181+
.setDescription("The overall number of records added or removed as part of the commit.")
182+
.setUnit("{record}")
183+
.build();
180184
}
181185

182186
static LongCounter addedFilesSize(Meter meter) {
183187
return meter
184-
.counterBuilder(ADDED_FILE_SIZE_BYTES)
185-
.setDescription("The overall size of the data and delete files added as part of the commit.")
186-
.setUnit("byte")
187-
.build();
188+
.counterBuilder(ADDED_FILE_SIZE_BYTES)
189+
.setDescription(
190+
"The overall size of the data and delete files added as part of the commit.")
191+
.setUnit("byte")
192+
.build();
188193
}
189194

190195
static LongCounter removedFilesSize(Meter meter) {
191196
return meter
192-
.counterBuilder(REMOVED_FILE_SIZE_BYTES)
193-
.setDescription("The overall size of the data or delete files removed as part of the commit.")
194-
.setUnit("byte")
195-
.build();
197+
.counterBuilder(REMOVED_FILE_SIZE_BYTES)
198+
.setDescription(
199+
"The overall size of the data or delete files removed as part of the commit.")
200+
.setUnit("byte")
201+
.build();
196202
}
197203

198204
static LongCounter totalFilesSize(Meter meter) {
199205
return meter
200-
.counterBuilder(TOTAL_FILE_SIZE_BYTES)
201-
.setDescription("The overall size of the data or delete files added or removed as part of the commit.")
202-
.setUnit("byte")
203-
.build();
206+
.counterBuilder(TOTAL_FILE_SIZE_BYTES)
207+
.setDescription(
208+
"The overall size of the data or delete files added or removed as part of the commit.")
209+
.setUnit("byte")
210+
.build();
204211
}
205212

206213
static LongCounter addedPositionDeletes(Meter meter) {
207214
return meter
208-
.counterBuilder(ADDED_POS_DELETES)
209-
.setDescription("The overall number of position delete entries added as part of the commit.")
210-
.setUnit("{record}")
211-
.build();
215+
.counterBuilder(ADDED_POS_DELETES)
216+
.setDescription(
217+
"The overall number of position delete entries added as part of the commit.")
218+
.setUnit("{record}")
219+
.build();
212220
}
213221

214222
static LongCounter removedPositionDeletes(Meter meter) {
215223
return meter
216-
.counterBuilder(REMOVED_POS_DELETES)
217-
.setDescription("The overall number of position delete entries removed as part of the commit.")
218-
.setUnit("{record}")
219-
.build();
224+
.counterBuilder(REMOVED_POS_DELETES)
225+
.setDescription(
226+
"The overall number of position delete entries removed as part of the commit.")
227+
.setUnit("{record}")
228+
.build();
220229
}
221230

222231
static LongCounter totalPositionDeletes(Meter meter) {
223232
return meter
224-
.counterBuilder(TOTAL_POS_DELETES)
225-
.setDescription("The overall number of position delete entries added or removed as part of the commit.")
226-
.setUnit("{record}")
227-
.build();
233+
.counterBuilder(TOTAL_POS_DELETES)
234+
.setDescription(
235+
"The overall number of position delete entries added or removed as part of the commit.")
236+
.setUnit("{record}")
237+
.build();
228238
}
229239

230240
static LongCounter addedEqualityDeletes(Meter meter) {
231241
return meter
232-
.counterBuilder(ADDED_EQ_DELETES)
233-
.setDescription("The overall number of equality delete entries added as part of the commit.")
234-
.setUnit("{record}")
235-
.build();
242+
.counterBuilder(ADDED_EQ_DELETES)
243+
.setDescription(
244+
"The overall number of equality delete entries added as part of the commit.")
245+
.setUnit("{record}")
246+
.build();
236247
}
237248

238249
static LongCounter removedEqualityDeletes(Meter meter) {
239250
return meter
240-
.counterBuilder(REMOVED_EQ_DELETES)
241-
.setDescription("The overall number of equality delete entries removed as part of the commit.")
242-
.setUnit("{record}")
243-
.build();
251+
.counterBuilder(REMOVED_EQ_DELETES)
252+
.setDescription(
253+
"The overall number of equality delete entries removed as part of the commit.")
254+
.setUnit("{record}")
255+
.build();
244256
}
245257

246258
static LongCounter totalEqualityDeletes(Meter meter) {
247259
return meter
248-
.counterBuilder(TOTAL_EQ_DELETES)
249-
.setDescription("The overall number of equality delete entries added or removed as part of the commit.")
250-
.setUnit("{record}")
251-
.build();
252-
}
253-
254-
static LongCounter keptManifests(Meter meter) {
255-
return meter
256-
.counterBuilder(KEPT_MANIFESTS_COUNT)
257-
.setDescription("The number of manifests that are kept as part of the commit.")
258-
.setUnit("{file}")
259-
.build();
260-
}
261-
262-
static LongCounter createdManfiests(Meter meter) {
263-
return meter
264-
.counterBuilder(CREATED_MANIFESTS_COUNT)
265-
.setDescription("The number of manifests that are created as part of the commit.")
266-
.setUnit("{file}")
267-
.build();
268-
}
269-
270-
static LongCounter replacedManifests(Meter meter) {
271-
return meter
272-
.counterBuilder(REPLACED_MANIFESTS_COUNT)
273-
.setDescription("The overall number of manifests that are deleted or overwritten as part of the commit.")
274-
.setUnit("{file}")
275-
.build();
276-
}
277-
278-
static LongCounter processedManfiestEntries(Meter meter) {
279-
return meter
280-
.counterBuilder(PROCESSED_MANIFEST_ENTRY_COUNT)
281-
.setDescription("The overall number of manifest entries (referenced files) that are processed as part of the commit.")
282-
.setUnit("{file}")
283-
.build();
260+
.counterBuilder(TOTAL_EQ_DELETES)
261+
.setDescription(
262+
"The overall number of equality delete entries added or removed as part of the commit.")
263+
.setUnit("{record}")
264+
.build();
284265
}
285266
}

0 commit comments

Comments
 (0)