1
- local metrics = require (' metrics' )
2
-
3
- local Shared = require (' metrics.collectors.shared' )
4
-
5
1
local has_mics_module , misc = pcall (require , ' misc' )
6
2
7
3
local LJ_PREFIX = ' lj_'
8
4
9
- local function prefix_name (name )
10
- return LJ_PREFIX .. name
11
- end
12
-
13
- local function set_gauge (name , description , value , labels )
14
- local gauge = metrics .gauge (prefix_name (name ), description )
15
- gauge :set (value , labels or {})
16
- return gauge
17
- end
18
-
19
- local function set_counter (name , description , value , labels )
20
- local counter = metrics .counter (prefix_name (name ), description )
21
- if counter .set == nil then
22
- counter .set = Shared .set
23
- end
24
- counter :set (value , labels or {})
25
- return counter
26
- end
5
+ local utils = require (' metrics.utils' )
27
6
28
7
local collectors_list = {}
29
8
@@ -34,46 +13,53 @@ local function update()
34
13
-- Details: https://github.com/tarantool/doc/issues/1597
35
14
local lj_metrics = misc .getmetrics ()
36
15
collectors_list .gc_freed =
37
- set_counter (' gc_freed' , ' Total amount of freed memory' , lj_metrics .gc_freed )
16
+ utils . set_counter (' gc_freed' , ' Total amount of freed memory' , lj_metrics .gc_freed , nil , LJ_PREFIX )
38
17
collectors_list .strhash_hit =
39
- set_counter (' strhash_hit' , ' Number of strings being interned' , lj_metrics .strhash_hit )
18
+ utils . set_counter (' strhash_hit' , ' Number of strings being interned' , lj_metrics .strhash_hit , nil , LJ_PREFIX )
40
19
collectors_list .gc_steps_atomic =
41
- set_counter (' gc_steps_atomic' , ' Count of incremental GC steps (atomic state)' , lj_metrics .gc_steps_atomic )
20
+ utils .set_counter (' gc_steps_atomic' , ' Count of incremental GC steps (atomic state)' ,
21
+ lj_metrics .gc_steps_atomic , nil , LJ_PREFIX )
42
22
collectors_list .strhash_miss =
43
- set_counter (' strhash_miss' , ' Total number of strings allocations during the platform lifetime' ,
44
- lj_metrics .strhash_miss )
23
+ utils . set_counter (' strhash_miss' , ' Total number of strings allocations during the platform lifetime' ,
24
+ lj_metrics .strhash_miss , nil , LJ_PREFIX )
45
25
collectors_list .gc_steps_sweepstring =
46
- set_counter (' gc_steps_sweepstring' , ' Count of incremental GC steps (sweepstring state)' ,
47
- lj_metrics .gc_steps_sweepstring )
26
+ utils . set_counter (' gc_steps_sweepstring' , ' Count of incremental GC steps (sweepstring state)' ,
27
+ lj_metrics .gc_steps_sweepstring , nil , LJ_PREFIX )
48
28
collectors_list .gc_strnum =
49
- set_gauge (' gc_strnum' , ' Amount of allocated string objects' , lj_metrics .gc_strnum )
29
+ utils . set_gauge (' gc_strnum' , ' Amount of allocated string objects' , lj_metrics .gc_strnum , nil , LJ_PREFIX )
50
30
collectors_list .gc_tabnum =
51
- set_gauge (' gc_tabnum' , ' Amount of allocated table objects' , lj_metrics .gc_tabnum )
31
+ utils . set_gauge (' gc_tabnum' , ' Amount of allocated table objects' , lj_metrics .gc_tabnum , nil , LJ_PREFIX )
52
32
collectors_list .gc_cdatanum =
53
- set_gauge (' gc_cdatanum' , ' Amount of allocated cdata objects' , lj_metrics .gc_cdatanum )
33
+ utils . set_gauge (' gc_cdatanum' , ' Amount of allocated cdata objects' , lj_metrics .gc_cdatanum , nil , LJ_PREFIX )
54
34
collectors_list .jit_snap_restore =
55
- set_counter (' jit_snap_restore' , ' Overall number of snap restores' , lj_metrics .jit_snap_restore )
35
+ utils .set_counter (' jit_snap_restore' , ' Overall number of snap restores' ,
36
+ lj_metrics .jit_snap_restore , nil , LJ_PREFIX )
56
37
collectors_list .gc_total =
57
- set_gauge (' gc_total' , ' Memory currently allocated' , lj_metrics .gc_total )
38
+ utils . set_gauge (' gc_total' , ' Memory currently allocated' , lj_metrics .gc_total , nil , LJ_PREFIX )
58
39
collectors_list .gc_udatanum =
59
- set_gauge (' gc_udatanum' , ' Amount of allocated udata objects' , lj_metrics .gc_udatanum )
40
+ utils . set_gauge (' gc_udatanum' , ' Amount of allocated udata objects' , lj_metrics .gc_udatanum , nil , LJ_PREFIX )
60
41
collectors_list .gc_steps_finalize =
61
- set_counter (' gc_steps_finalize' , ' Count of incremental GC steps (finalize state)' , lj_metrics .gc_steps_finalize )
42
+ utils .set_counter (' gc_steps_finalize' , ' Count of incremental GC steps (finalize state)' ,
43
+ lj_metrics .gc_steps_finalize , nil , LJ_PREFIX )
62
44
collectors_list .gc_allocated =
63
- set_counter (' gc_allocated' , ' Total amount of allocated memory' , lj_metrics .gc_allocated )
45
+ utils . set_counter (' gc_allocated' , ' Total amount of allocated memory' , lj_metrics .gc_allocated , nil , LJ_PREFIX )
64
46
collectors_list .jit_trace_num =
65
- set_gauge (' jit_trace_num' , ' Amount of JIT traces' , lj_metrics .jit_trace_num )
47
+ utils . set_gauge (' jit_trace_num' , ' Amount of JIT traces' , lj_metrics .jit_trace_num , nil , LJ_PREFIX )
66
48
collectors_list .gc_steps_sweep =
67
- set_counter (' gc_steps_sweep' , ' Count of incremental GC steps (sweep state)' , lj_metrics .gc_steps_sweep )
49
+ utils .set_counter (' gc_steps_sweep' , ' Count of incremental GC steps (sweep state)' ,
50
+ lj_metrics .gc_steps_sweep , nil , LJ_PREFIX )
68
51
collectors_list .jit_trace_abort =
69
- set_counter (' jit_trace_abort' , ' Overall number of abort traces' , lj_metrics .jit_trace_abort )
52
+ utils .set_counter (' jit_trace_abort' , ' Overall number of abort traces' ,
53
+ lj_metrics .jit_trace_abort , nil , LJ_PREFIX )
70
54
collectors_list .jit_mcode_size =
71
- set_gauge (' jit_mcode_size' , ' Total size of all allocated machine code areas' , lj_metrics .jit_mcode_size )
55
+ utils .set_gauge (' jit_mcode_size' , ' Total size of all allocated machine code areas' ,
56
+ lj_metrics .jit_mcode_size , nil , LJ_PREFIX )
72
57
collectors_list .gc_steps_propagate =
73
- set_counter (' gc_steps_propagate' , ' Count of incremental GC steps (propagate state)' ,
74
- lj_metrics .gc_steps_propagate )
58
+ utils . set_counter (' gc_steps_propagate' , ' Count of incremental GC steps (propagate state)' ,
59
+ lj_metrics .gc_steps_propagate , nil , LJ_PREFIX )
75
60
collectors_list .gc_steps_pause =
76
- set_counter (' gc_steps_pause' , ' Count of incremental GC steps (pause state)' , lj_metrics .gc_steps_pause )
61
+ utils .set_counter (' gc_steps_pause' , ' Count of incremental GC steps (pause state)' ,
62
+ lj_metrics .gc_steps_pause , nil , LJ_PREFIX )
77
63
end
78
64
79
65
return {
0 commit comments