@@ -20,6 +20,9 @@ local metric_name = {
2020 -- Counter collector for spaces not found.
2121 space_not_found = ' tnt_crud_space_not_found' ,
2222
23+ -- Counter collector for schema reloads.
24+ schema_reloads = ' tnt_crud_schema_reloads' ,
25+
2326 -- Counter collectors for select/pairs details.
2427 details = {
2528 tuples_fetched = ' tnt_crud_tuples_fetched' ,
@@ -110,6 +113,10 @@ function registry.init(opts)
110113 metric_name .space_not_found ,
111114 ' Spaces not found during CRUD calls' )
112115
116+ internal .registry [metric_name .schema_reloads ] = metrics .counter (
117+ metric_name .schema_reloads ,
118+ ' Schema reloads performed in operation calls' )
119+
113120 internal .registry [metric_name .details .tuples_fetched ] = metrics .counter (
114121 metric_name .details .tuples_fetched ,
115122 ' Tuples fetched from CRUD storages during select/pairs' )
@@ -210,6 +217,7 @@ function registry.get(space_name)
210217 local stats = {
211218 spaces = {},
212219 space_not_found = 0 ,
220+ schema_reloads = 0 ,
213221 }
214222
215223 -- Fill operation basic statistics values.
@@ -264,9 +272,14 @@ function registry.get(space_name)
264272 return stats .spaces [space_name ] or {}
265273 end
266274
267- local _ , obs = next (internal .registry [metric_name .space_not_found ]:collect ())
268- if obs ~= nil then
269- stats .space_not_found = obs .value
275+ local _ , not_found_obs = next (internal .registry [metric_name .space_not_found ]:collect ())
276+ if not_found_obs ~= nil then
277+ stats .space_not_found = not_found_obs .value
278+ end
279+
280+ local _ , reload_obs = next (internal .registry [metric_name .schema_reloads ]:collect ())
281+ if reload_obs ~= nil then
282+ stats .schema_reloads = reload_obs .value
270283 end
271284
272285 return stats
@@ -396,6 +409,23 @@ function registry.observe_map_reduces(count, space_name)
396409 return true
397410end
398411
412+ --- Increase statistics of schema reloads
413+ --
414+ -- @function observe_schema_reloads
415+ --
416+ -- @tparam number count
417+ -- Schema reloads performed.
418+ --
419+ -- @treturn boolean Returns true.
420+ --
421+ function registry .observe_schema_reloads (count )
422+ dev_checks (' number' )
423+
424+ internal .registry [metric_name .schema_reloads ]:inc (count )
425+
426+ return true
427+ end
428+
399429-- Workaround for https://github.com/tarantool/metrics/issues/334 .
400430-- This workaround does not prevent observations reset between role reloads,
401431-- but it fixes collector unlink from registry. Without this workaround,
0 commit comments