@@ -171,6 +171,15 @@ class _KlioInputDataMixin(object):
171
171
172
172
DIRECTION_PFX = KlioIODirection .INPUT
173
173
174
+ def setup (self , * args , ** kwargs ):
175
+ super (_KlioInputDataMixin , self ).setup (* args , ** kwargs )
176
+ self .found_ctr = self ._klio .metrics .counter (
177
+ "kmsg-data-found-input" , transform = self ._transform_name
178
+ )
179
+ self .not_found_ctr = self ._klio .metrics .counter (
180
+ "kmsg-data-not-found-input" , transform = self ._transform_name
181
+ )
182
+
174
183
@property
175
184
def _data_config (self ):
176
185
# TODO: figure out how to support multiple inputs
@@ -198,6 +207,11 @@ def _data_config(self):
198
207
)
199
208
return self ._klio .config .job_config .data .inputs [0 ]
200
209
210
+ @property
211
+ def _transform_name (self ):
212
+ # grab the child class name that inherits this class, if any
213
+ return self .__class__ .__name__
214
+
201
215
202
216
class _KlioOutputDataMixin (object ):
203
217
"""Mixin to add output-specific logic for a data existence check.
@@ -207,6 +221,15 @@ class _KlioOutputDataMixin(object):
207
221
208
222
DIRECTION_PFX = KlioIODirection .OUTPUT
209
223
224
+ def setup (self , * args , ** kwargs ):
225
+ super (_KlioOutputDataMixin , self ).setup (* args , ** kwargs )
226
+ self .found_ctr = self ._klio .metrics .counter (
227
+ "kmsg-data-found-output" , transform = self ._transform_name
228
+ )
229
+ self .not_found_ctr = self ._klio .metrics .counter (
230
+ "kmsg-data-not-found-output" , transform = self ._transform_name
231
+ )
232
+
210
233
@property
211
234
def _data_config (self ):
212
235
# TODO: figure out how to support multiple outputs
@@ -235,6 +258,11 @@ def _data_config(self):
235
258
)
236
259
return self ._klio .config .job_config .data .outputs [0 ]
237
260
261
+ @property
262
+ def _transform_name (self ):
263
+ # grab the child class name that inherits this class, if any
264
+ return self .__class__ .__name__
265
+
238
266
239
267
class _KlioGcsDataExistsMixin (object ):
240
268
"""Mixin for GCS-specific data existence check logic.
@@ -243,7 +271,8 @@ class _KlioGcsDataExistsMixin(object):
243
271
_KlioInputDataMixin or _KlioOutputDataMixin
244
272
"""
245
273
246
- def setup (self ):
274
+ def setup (self , * args , ** kwargs ):
275
+ super (_KlioGcsDataExistsMixin , self ).setup (* args , ** kwargs )
247
276
self .client = gcsio .GcsIO ()
248
277
249
278
def exists (self , path ):
@@ -260,9 +289,12 @@ def process(self, kmsg):
260
289
item_path = self ._get_absolute_path (item )
261
290
item_exists = self .exists (item_path )
262
291
263
- state = DataExistState .FOUND
264
292
if not item_exists :
293
+ self .not_found_ctr .inc ()
265
294
state = DataExistState .NOT_FOUND
295
+ else :
296
+ self .found_ctr .inc ()
297
+ state = DataExistState .FOUND
266
298
267
299
self ._klio .logger .info (
268
300
"%s %s at %s"
0 commit comments