Skip to content

Commit 23cf464

Browse files
Fix statistics module ldoc descriptions
Follows PR review. Use ldoc aliases for types and [opt] for optional parameters. Fix typos and outdated info in descriptions. Fix incorrect description of argument table fields. Use @Local for local functions. Wrap language constructions in backticks. It is not clear how to describe modules with constants for ldoc. ldoc-styled description for `crud.stats.operation` is available at `crud.stats.module`. See [1] for possible updates. 1. lunarmodules/ldoc#369 Follows up #224
1 parent 6c39115 commit 23cf464

File tree

6 files changed

+202
-143
lines changed

6 files changed

+202
-143
lines changed

crud/stats/local_registry.lua

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---- Module
2+
-- @module crud.stats.local_registry
3+
--
14
local errors = require('errors')
25

36
local dev_checks = require('crud.common.dev_checks')
@@ -9,18 +12,19 @@ local registry = {}
912
local internal = stash.get('local_registry')
1013
local StatsLocalError = errors.new_class('StatsLocalError', {capture_stack = false})
1114

12-
--- Initialize local metrics registry
15+
--- Initialize local metrics registry.
1316
--
1417
-- Registries are not meant to used explicitly
1518
-- by users, init is not guaranteed to be idempotent.
1619
--
1720
-- @function init
18-
-- @tparam table opts
1921
--
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.
2226
--
23-
-- @treturn boolean Returns true.
27+
-- @treturn boolean Returns `true`.
2428
--
2529
function registry.init(opts)
2630
dev_checks({ quantiles = 'boolean' })
@@ -36,35 +40,35 @@ function registry.init(opts)
3640
return true
3741
end
3842

39-
--- Destroy local metrics registry
43+
--- Destroy local metrics registry.
4044
--
4145
-- Registries are not meant to used explicitly
4246
-- by users, destroy is not guaranteed to be idempotent.
4347
--
4448
-- @function destroy
4549
--
46-
-- @treturn boolean Returns true.
50+
-- @treturn boolean Returns `true`.
4751
--
4852
function registry.destroy()
4953
internal.registry = nil
5054

5155
return true
5256
end
5357

54-
--- Get copy of local metrics registry
58+
--- Get copy of local metrics registry.
5559
--
5660
-- Registries are not meant to used explicitly
5761
-- by users, get is not guaranteed to work without init.
5862
--
5963
-- @function get
6064
--
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
6367
-- of operations on table, separated by operation type and
6468
-- 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.
6872
--
6973
-- @treturn table Returns copy of metrics registry (or registry section).
7074
--
@@ -78,39 +82,39 @@ function registry.get(space_name)
7882
return table.deepcopy(internal.registry)
7983
end
8084

81-
--- Check if space statistics are present in registry
85+
--- Check if space statistics are present in registry.
8286
--
8387
-- @function is_unknown_space
8488
--
85-
-- @tparam string space_name
89+
-- @string space_name
8690
-- Name of space.
8791
--
88-
-- @treturn boolean True, if space stats found. False otherwise.
92+
-- @treturn boolean `true`, if space stats found. `false` otherwise.
8993
--
9094
function registry.is_unknown_space(space_name)
9195
dev_checks('string')
9296

9397
return internal.registry.spaces[space_name] == nil
9498
end
9599

96-
--- Increase requests count and update latency info
100+
--- Increase requests count and update latency info.
97101
--
98102
-- @function observe
99103
--
100-
-- @tparam string space_name
104+
-- @string space_name
101105
-- Name of space.
102106
--
103-
-- @tparam number latency
107+
-- @number latency
104108
-- Time of call execution.
105109
--
106-
-- @tparam string op
110+
-- @string op
107111
-- Label of registry collectors.
108-
-- Use `require('crud.common.const').OP` to pick one.
112+
-- Use `require('crud.stats.module').op` to pick one.
109113
--
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.
112116
--
113-
-- @treturn boolean Returns true.
117+
-- @treturn boolean Returns `true`.
114118
--
115119
function registry.observe(latency, space_name, op, status)
116120
dev_checks('number', 'string', 'string', 'string')
@@ -125,32 +129,32 @@ function registry.observe(latency, space_name, op, status)
125129
return true
126130
end
127131

128-
--- Increase count of "space not found" collector by one
132+
--- Increase count of "space not found" collector by one.
129133
--
130134
-- @function observe_space_not_found
131135
--
132-
-- @treturn boolean Returns true.
136+
-- @treturn boolean Returns `true`.
133137
--
134138
function registry.observe_space_not_found()
135139
internal.registry.space_not_found = internal.registry.space_not_found + 1
136140

137141
return true
138142
end
139143

140-
--- Increase statistics of storage select/pairs calls
144+
--- Increase statistics of storage select/pairs calls.
141145
--
142146
-- @function observe_fetch
143147
--
144-
-- @tparam string space_name
148+
-- @string space_name
145149
-- Name of space.
146150
--
147-
-- @tparam number tuples_fetched
151+
-- @number tuples_fetched
148152
-- Count of tuples fetched during storage call.
149153
--
150-
-- @tparam number tuples_lookup
154+
-- @number tuples_lookup
151155
-- Count of tuples looked up on storages while collecting response.
152156
--
153-
-- @treturn boolean Returns true.
157+
-- @treturn boolean Returns `true`.
154158
--
155159
function registry.observe_fetch(tuples_fetched, tuples_lookup, space_name)
156160
dev_checks('number', 'number', 'string')
@@ -165,17 +169,17 @@ function registry.observe_fetch(tuples_fetched, tuples_lookup, space_name)
165169
return true
166170
end
167171

168-
--- Increase statistics of planned map reduces during select/pairs
172+
--- Increase statistics of planned map reduces during select/pairs.
169173
--
170174
-- @function observe_map_reduces
171175
--
172-
-- @tparam number count
176+
-- @number count
173177
-- Count of map reduces planned.
174178
--
175-
-- @tparam string space_name
179+
-- @string space_name
176180
-- Name of space.
177181
--
178-
-- @treturn boolean Returns true.
182+
-- @treturn boolean Returns `true`.
179183
--
180184
function registry.observe_map_reduces(count, space_name)
181185
dev_checks('number', 'string')
@@ -189,14 +193,14 @@ function registry.observe_map_reduces(count, space_name)
189193
return true
190194
end
191195

192-
--- Increase statistics of schema reloads
196+
--- Increase statistics of schema reloads.
193197
--
194198
-- @function observe_schema_reloads
195199
--
196-
-- @tparam number count
200+
-- @number count
197201
-- Schema reloads performed.
198202
--
199-
-- @treturn boolean Returns true.
203+
-- @treturn boolean Returns `true`.
200204
--
201205
function registry.observe_schema_reloads(count)
202206
dev_checks('number')

0 commit comments

Comments
 (0)