-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics.cfg is a module configuration entrypoint [1]. After this patch, box.cfg{metrics = cfg} triggers metrics.cfg. Parameter is dynamic. This patch also enables all metrics by default. To disable them, use box.cfg{metrics = {include = 'none'}}. Since callbacks are triggered manually (when user calls `invoke_callbacks()` or `collect{invoke_callbacks=true}`), it should not affect the performance. 1. https://www.tarantool.io/en/doc/latest/book/monitoring/api_reference/#lua-function.metrics.cfg Closes #7725 @TarantoolBot document Title: embedded metrics configuration This patch add new box.cfg dynamic parameter: metrics. It is a table with the same effect as in metrics.cfg. metrics.cfg has its own documentation, see [1]. 1. https://www.tarantool.io/en/doc/latest/book/monitoring/api_reference/#lua-function.metrics.cfg
- Loading branch information
1 parent
82ebbb3
commit 8f95eaa
Showing
6 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
## feature/lua | ||
|
||
* Embed tarantool/metrics module for metrics aggregation and export (gh-7725). | ||
* Configure metrics with box.cfg (gh-7725). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
require('test.metrics-luatest.helper') | ||
|
||
local t = require('luatest') | ||
local g = t.group('box-cfg-metrics') | ||
local server = require('luatest.server') | ||
|
||
local utils = require('third_party.metrics.test.utils') | ||
|
||
g.before_all(function() | ||
g.server = server:new() | ||
g.server:start() | ||
end) | ||
|
||
g.after_all(function() | ||
g.server:drop() | ||
end) | ||
|
||
g.before_each(function() | ||
g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
include = 'all', | ||
exclude = {}, | ||
labels = {}, | ||
} | ||
} | ||
end) | ||
end) | ||
|
||
g.test_include = function() | ||
local default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
include = {'info'}, | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
local uptime = utils.find_metric('tnt_info_uptime', default_metrics) | ||
t.assert_not_equals(uptime, nil) | ||
local memlua = utils.find_metric('tnt_info_memory_lua', default_metrics) | ||
t.assert_equals(memlua, nil) | ||
end | ||
|
||
g.test_exclude = function() | ||
local default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
exclude = {'memory'}, | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
local uptime = utils.find_metric('tnt_info_uptime', default_metrics) | ||
t.assert_not_equals(uptime, nil) | ||
local memlua = utils.find_metric('tnt_info_memory_lua', default_metrics) | ||
t.assert_equals(memlua, nil) | ||
end | ||
|
||
g.test_include_with_exclude = function() | ||
local default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
include = {'info', 'memory'}, | ||
exclude = {'memory'}, | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
local uptime = utils.find_metric('tnt_info_uptime', default_metrics) | ||
t.assert_not_equals(uptime, nil) | ||
local memlua = utils.find_metric('tnt_info_memory_lua', default_metrics) | ||
t.assert_equals(memlua, nil) | ||
end | ||
|
||
g.test_include_none = function() | ||
local default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
include = 'none', | ||
exclude = {'memory'}, | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
t.assert_equals(default_metrics, {}) | ||
end | ||
|
||
g.test_labels = function() | ||
local default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
labels = {mylabel = 'myvalue'} | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
local uptime = utils.find_obs('tnt_info_uptime', {mylabel = 'myvalue'}, | ||
default_metrics) | ||
t.assert_equals(uptime.label_pairs, {mylabel = 'myvalue'}) | ||
|
||
default_metrics = g.server:exec(function() | ||
box.cfg{ | ||
metrics = { | ||
labels = {} | ||
} | ||
} | ||
|
||
return require('metrics').collect{invoke_callbacks = true} | ||
end) | ||
|
||
uptime = utils.find_obs('tnt_info_uptime', {}, default_metrics) | ||
t.assert_equals(uptime.label_pairs, {}) | ||
end |