Skip to content

Commit

Permalink
doc: use extended format in custom plugin build
Browse files Browse the repository at this point in the history
Advice users to iterate through extensive
metrics.collect{extended_format = true} output instead of collectors.

Part of tarantool/tarantool#7725
Part of tarantool/tarantool#7728
  • Loading branch information
DifferentialOrange committed Feb 15, 2023
1 parent 97c29d8 commit cfcc861
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions doc/monitoring/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,23 @@ Include the following in your main export function:

.. code-block:: lua
-- Invoke all callbacks registered via `metrics.register_callback(<callback-function>)`
metrics.invoke_callbacks()
local metrics = require('metrics')
local string_utils = require('metrics.string_utils')
-- Loop over collectors
for _, c in pairs(metrics.collectors()) do
...
-- Collect up-to-date metrics with extended format.
local output = metrics.collect{invoke_callbacks = true, extended_format = true}
-- Loop over instant observations in the collector
for _, obs in pairs(c:collect()) do
-- Export observation `obs`
...
end
for _, coll_obs in pairs(output) do
-- Serialize collector info like coll_obs.name, coll_obs.help,
-- coll_obs.kind and coll_obs.timestamp
for group_name, obs_group in pairs(coll_obs.observations) do
-- Common way to build metric name.
local metric_name = string_utils.build_name(coll_obs.name, group_name)
for _, obs in pairs(obs_group) do
-- Serialize observation info: obs.value and obs.label_pairs
end
end
end

0 comments on commit cfcc861

Please sign in to comment.