1
+ ---- Module
2
+ -- @module crud.stats.local_registry
3
+ --
1
4
local errors = require (' errors' )
2
5
3
6
local dev_checks = require (' crud.common.dev_checks' )
@@ -9,18 +12,19 @@ local registry = {}
9
12
local internal = stash .get (' local_registry' )
10
13
local StatsLocalError = errors .new_class (' StatsLocalError' , {capture_stack = false })
11
14
12
- --- Initialize local metrics registry
15
+ --- Initialize local metrics registry.
13
16
--
14
17
-- Registries are not meant to used explicitly
15
18
-- by users, init is not guaranteed to be idempotent.
16
19
--
17
20
-- @function init
18
- -- @tparam table opts
19
21
--
20
- -- @tfield boolean quantiles
21
- -- Quantiles is not supported for local, only `false` is valid.
22
+ -- @tab opts
23
+ --
24
+ -- @bool opts.quantiles
25
+ -- Quantiles is not supported for local, only `false` is valid.
22
26
--
23
- -- @treturn boolean Returns true.
27
+ -- @treturn boolean Returns ` true` .
24
28
--
25
29
function registry .init (opts )
26
30
dev_checks ({ quantiles = ' boolean' })
@@ -36,35 +40,35 @@ function registry.init(opts)
36
40
return true
37
41
end
38
42
39
- --- Destroy local metrics registry
43
+ --- Destroy local metrics registry.
40
44
--
41
45
-- Registries are not meant to used explicitly
42
46
-- by users, destroy is not guaranteed to be idempotent.
43
47
--
44
48
-- @function destroy
45
49
--
46
- -- @treturn boolean Returns true.
50
+ -- @treturn boolean Returns ` true` .
47
51
--
48
52
function registry .destroy ()
49
53
internal .registry = nil
50
54
51
55
return true
52
56
end
53
57
54
- --- Get copy of local metrics registry
58
+ --- Get copy of local metrics registry.
55
59
--
56
60
-- Registries are not meant to used explicitly
57
61
-- by users, get is not guaranteed to work without init.
58
62
--
59
63
-- @function get
60
64
--
61
- -- @tparam string space_name
62
- -- (Optional) If specified, returns table with statistics
65
+ -- @string[opt] space_name
66
+ -- If specified, returns table with statistics
63
67
-- of operations on table, separated by operation type and
64
68
-- execution status. If there wasn't any requests for table,
65
- -- returns {}. In not specified, returns table with statistics
66
- -- about all existing spaces and count of calls to spaces
67
- -- that wasn't found.
69
+ -- returns `{}`. If not specified, returns table with statistics
70
+ -- about all existing spaces, count of calls to spaces
71
+ -- that wasn't found and count of schema reloads .
68
72
--
69
73
-- @treturn table Returns copy of metrics registry (or registry section).
70
74
--
@@ -78,39 +82,39 @@ function registry.get(space_name)
78
82
return table .deepcopy (internal .registry )
79
83
end
80
84
81
- --- Check if space statistics are present in registry
85
+ --- Check if space statistics are present in registry.
82
86
--
83
87
-- @function is_unknown_space
84
88
--
85
- -- @tparam string space_name
89
+ -- @string space_name
86
90
-- Name of space.
87
91
--
88
- -- @treturn boolean True , if space stats found. False otherwise.
92
+ -- @treturn boolean `true` , if space stats found. `false` otherwise.
89
93
--
90
94
function registry .is_unknown_space (space_name )
91
95
dev_checks (' string' )
92
96
93
97
return internal .registry .spaces [space_name ] == nil
94
98
end
95
99
96
- --- Increase requests count and update latency info
100
+ --- Increase requests count and update latency info.
97
101
--
98
102
-- @function observe
99
103
--
100
- -- @tparam string space_name
104
+ -- @string space_name
101
105
-- Name of space.
102
106
--
103
- -- @tparam number latency
107
+ -- @number latency
104
108
-- Time of call execution.
105
109
--
106
- -- @tparam string op
110
+ -- @string op
107
111
-- Label of registry collectors.
108
- -- Use `require('crud.common.const ').OP ` to pick one.
112
+ -- Use `require('crud.stats.module ').op ` to pick one.
109
113
--
110
- -- @tparam string success
111
- -- 'ok' if no errors on execution, 'error' otherwise.
114
+ -- @string success
115
+ -- ` 'ok'` if no errors on execution, ` 'error'` otherwise.
112
116
--
113
- -- @treturn boolean Returns true.
117
+ -- @treturn boolean Returns ` true` .
114
118
--
115
119
function registry .observe (latency , space_name , op , status )
116
120
dev_checks (' number' , ' string' , ' string' , ' string' )
@@ -125,32 +129,32 @@ function registry.observe(latency, space_name, op, status)
125
129
return true
126
130
end
127
131
128
- --- Increase count of "space not found" collector by one
132
+ --- Increase count of "space not found" collector by one.
129
133
--
130
134
-- @function observe_space_not_found
131
135
--
132
- -- @treturn boolean Returns true.
136
+ -- @treturn boolean Returns ` true` .
133
137
--
134
138
function registry .observe_space_not_found ()
135
139
internal .registry .space_not_found = internal .registry .space_not_found + 1
136
140
137
141
return true
138
142
end
139
143
140
- --- Increase statistics of storage select/pairs calls
144
+ --- Increase statistics of storage select/pairs calls.
141
145
--
142
146
-- @function observe_fetch
143
147
--
144
- -- @tparam string space_name
148
+ -- @string space_name
145
149
-- Name of space.
146
150
--
147
- -- @tparam number tuples_fetched
151
+ -- @number tuples_fetched
148
152
-- Count of tuples fetched during storage call.
149
153
--
150
- -- @tparam number tuples_lookup
154
+ -- @number tuples_lookup
151
155
-- Count of tuples looked up on storages while collecting response.
152
156
--
153
- -- @treturn boolean Returns true.
157
+ -- @treturn boolean Returns ` true` .
154
158
--
155
159
function registry .observe_fetch (tuples_fetched , tuples_lookup , space_name )
156
160
dev_checks (' number' , ' number' , ' string' )
@@ -165,17 +169,17 @@ function registry.observe_fetch(tuples_fetched, tuples_lookup, space_name)
165
169
return true
166
170
end
167
171
168
- --- Increase statistics of planned map reduces during select/pairs
172
+ --- Increase statistics of planned map reduces during select/pairs.
169
173
--
170
174
-- @function observe_map_reduces
171
175
--
172
- -- @tparam number count
176
+ -- @number count
173
177
-- Count of map reduces planned.
174
178
--
175
- -- @tparam string space_name
179
+ -- @string space_name
176
180
-- Name of space.
177
181
--
178
- -- @treturn boolean Returns true.
182
+ -- @treturn boolean Returns ` true` .
179
183
--
180
184
function registry .observe_map_reduces (count , space_name )
181
185
dev_checks (' number' , ' string' )
@@ -189,14 +193,14 @@ function registry.observe_map_reduces(count, space_name)
189
193
return true
190
194
end
191
195
192
- --- Increase statistics of schema reloads
196
+ --- Increase statistics of schema reloads.
193
197
--
194
198
-- @function observe_schema_reloads
195
199
--
196
- -- @tparam number count
200
+ -- @number count
197
201
-- Schema reloads performed.
198
202
--
199
- -- @treturn boolean Returns true.
203
+ -- @treturn boolean Returns ` true` .
200
204
--
201
205
function registry .observe_schema_reloads (count )
202
206
dev_checks (' number' )
0 commit comments