Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new metrics category: cpu extended #498

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/push-translation.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Push translation sources

on:
pull_request:
paths:
- 'doc/**/*'
workflow_dispatch # Temporarily switched off
# pull_request:
# paths:
# - 'doc/**/*'
jobs:
push-translation-sources:
runs-on: ubuntu-20.04
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- New metrics category in config: ``cpu_extended``.

### Fixed
- Use box.info.ro instead of box.cfg.read_only in replication metrics.

Expand Down
1 change: 1 addition & 0 deletions doc/monitoring/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ Metrics functions
* ``clock``
* ``event_loop``
* ``config``
* ``cpu_extended``

See :ref:`metrics reference <metrics-reference>` for details.
All metric collectors from the collection have ``metainfo.default = true``.
Expand Down
2 changes: 2 additions & 0 deletions metrics/tarantool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local utils = require('metrics.utils')
local const = require('metrics.const')

local default_metrics = {
-- category = {update: function, list: table},
network = require('metrics.tarantool.network'),
operations = require('metrics.tarantool.operations'),
system = require('metrics.tarantool.system'),
Expand All @@ -24,6 +25,7 @@ local default_metrics = {
clock = require('metrics.tarantool.clock'),
event_loop = require('metrics.tarantool.event_loop'),
config = require('metrics.tarantool.config'),
cpu_extended = require('metrics.psutils.cpu'),
}

local all_metrics_map = {}
Expand Down
79 changes: 47 additions & 32 deletions test/cfg_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,38 +127,53 @@ group.test_table_is_immutable = function(g)
end)
end

group.test_include = function(g)
g.server:exec(function()
local metrics = require('metrics')
local utils = require('test.utils') -- luacheck: ignore 431

metrics.cfg{
include = {'info'},
}

local default_metrics = metrics.collect{invoke_callbacks = true}
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)
end

group.test_exclude = function(g)
g.server:exec(function()
local metrics = require('metrics')
local utils = require('test.utils') -- luacheck: ignore 431

metrics.cfg{
exclude = {'memory'},
}

local default_metrics = metrics.collect{invoke_callbacks = true}
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)
local matrix = {
-- {category: string, includes: string, excludes: string, linux_only: boolean}
{'info', 'tnt_info_uptime', 'tnt_info_memory_lua'},
{'cpu_extended', 'tnt_cpu_thread', 'tnt_info_memory_lua', true},
{'network', 'tnt_net_sent_total', 'tnt_info_memory_lua'},
{'operations', 'tnt_stats_op_total', 'tnt_info_memory_lua'},
{'system', 'tnt_cfg_current_time', 'tnt_info_memory_lua'},
-- TODO: add more caterories
}

for _, row in ipairs(matrix) do
local m_category, m_include, m_exclude, m_linux_only = unpack(row)

group[('test_include_%s'):format(m_category)] = function(g)
g.server:exec(function(category, include, exclude, linux_only)
t.skip_if(linux_only and jit.os ~= 'Linux', 'Linux is the only supported platform')
local metrics = require('metrics')
local utils = require('test.utils') -- luacheck: ignore 431

metrics.cfg{
include = {category},
}

local default_metrics = metrics.collect{invoke_callbacks = true}
local included = utils.find_metric(include, default_metrics)
t.assert_not_equals(included, nil)
local excluded = utils.find_metric(exclude, default_metrics)
t.assert_equals(excluded, nil)
end, {m_category, m_include, m_exclude, m_linux_only})
end
group[('test_exclude_%s'):format(m_category)] = function(g)
g.server:exec(function(category, include, exclude, linux_only)
t.skip_if(linux_only and jit.os ~= 'Linux', 'Linux is the only supported platform')
local metrics = require('metrics')
local utils = require('test.utils') -- luacheck: ignore 431

metrics.cfg{
exclude = {category},
}

local default_metrics = metrics.collect{invoke_callbacks = true}
local uptime = utils.find_metric(exclude, default_metrics)
t.assert_not_equals(uptime, nil)
local memlua = utils.find_metric(include, default_metrics)
t.assert_equals(memlua, nil)
end, {m_category, m_include, m_exclude, m_linux_only})
end
end

group.test_include_with_exclude = function(g)
Expand Down
Loading