From 490b5501bb10bf705927c564474176bf4f3ff4b4 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Mon, 3 Feb 2025 19:42:56 +0300 Subject: [PATCH 1/3] Add new metrics category: cpu extended --- CHANGELOG.md | 3 ++ metrics/tarantool.lua | 2 ++ test/cfg_test.lua | 79 +++++++++++++++++++++++++------------------ 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f7f08e..0443308e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/metrics/tarantool.lua b/metrics/tarantool.lua index b3b57612..15db28e0 100644 --- a/metrics/tarantool.lua +++ b/metrics/tarantool.lua @@ -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'), @@ -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 = {} diff --git a/test/cfg_test.lua b/test/cfg_test.lua index e77875b0..b3243c20 100644 --- a/test/cfg_test.lua +++ b/test/cfg_test.lua @@ -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) From ce9cd6eab5712e60bdbe209a757048a4893d76d6 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Mon, 3 Feb 2025 20:30:16 +0300 Subject: [PATCH 2/3] Add docs --- doc/monitoring/api_reference.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/monitoring/api_reference.rst b/doc/monitoring/api_reference.rst index 5ebefbe4..0d93fb9e 100644 --- a/doc/monitoring/api_reference.rst +++ b/doc/monitoring/api_reference.rst @@ -567,6 +567,7 @@ Metrics functions * ``clock`` * ``event_loop`` * ``config`` + * ``cpu_extended`` See :ref:`metrics reference ` for details. All metric collectors from the collection have ``metainfo.default = true``. From 6e7656c0b1c70f3c836b6b966598c867600034fe Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Thu, 20 Feb 2025 13:43:49 +0300 Subject: [PATCH 3/3] Disable push translation workflow --- .github/workflows/push-translation.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push-translation.yml b/.github/workflows/push-translation.yml index 6d20f27e..223405f1 100644 --- a/.github/workflows/push-translation.yml +++ b/.github/workflows/push-translation.yml @@ -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