Skip to content

Commit

Permalink
rock: override built-in metrics
Browse files Browse the repository at this point in the history
The ability to override built-in modules was introduced with [1]. To use
it, you must install the package files using the override.package path
for each file included.

Using soft links inside the rock seems like a bad idea -- luarocks try
to resolve them on files deploy and fails to do so. The only stable
approach is seems to be to duplicate the files to the override
folder.

builtin rockspec doesn't allow to specify a single file twice, so we
need to store the soft link in the repo to workaround it. To build
override package with builtin rockspec, we'll also need to manually
maintain two lists of package files. On the other hand, soft link in
repo allows to work with files locally ever without package rebuild.

After [2], metrics will be embedded to core Tarantool. The ability to
override them with installed rock will make it possible to use old
Tarantool with new metrics. cartridge role, which was embedded to
tarantool/cartridge in [3], is also would be override.

1. tarantool/tarantool#7774
2. tarantool/tarantool#7725
3. tarantool/cartridge#2047

Closes tarantool/tarantool#7727
  • Loading branch information
DifferentialOrange committed Mar 23, 2023
1 parent d922704 commit 78a47ba
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:
with:
module-name: 'metrics'
version-pre-extraction-hook: |
local rock_utils = require('test.rock_utils')
rock_utils.remove_builtin('metrics')
rock_utils.assert_nonbuiltin('metrics')
require('test.rock_utils').assert_nonbuiltin('metrics')
package:
# Skip pull request jobs when the source branch is in the same
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/push_rockspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
with:
module-name: 'metrics'
version-pre-extraction-hook: |
local rock_utils = require('test.rock_utils')
rock_utils.remove_builtin('metrics')
rock_utils.assert_nonbuiltin('metrics')
require('test.rock_utils').assert_nonbuiltin('metrics')
push-scm-rockspec:
runs-on: [ ubuntu-20.04 ]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ doc/output/
doc/locale/en/

*.lua.c

packpack
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `'all'` and `'none'` options for `include` argument,
- simultaneous `include` and `exclude` arguments
(`exclude` has higher priority)
- Override built-in metrics, if installed

### Deprecated
- Passing nonexistent metrics to `enable_default_metrics()`
Expand Down
42 changes: 42 additions & 0 deletions metrics-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,48 @@ build = {
['metrics.version'] = 'metrics/version.lua',
['cartridge.roles.metrics'] = 'cartridge/roles/metrics.lua',
['cartridge.health'] = 'cartridge/health.lua',

['override.metrics'] = 'override/metrics/init.lua',
['override.metrics.api'] = 'override/metrics/api.lua',
['override.metrics.registry'] = 'override/metrics/registry.lua',
['override.metrics.quantile'] = 'override/metrics/quantile.lua',
['override.metrics.http_middleware'] = 'override/metrics/http_middleware.lua',
['override.metrics.collectors.shared'] = 'override/metrics/collectors/shared.lua',
['override.metrics.collectors.summary'] = 'override/metrics/collectors/summary.lua',
['override.metrics.collectors.counter'] = 'override/metrics/collectors/counter.lua',
['override.metrics.collectors.gauge'] = 'override/metrics/collectors/gauge.lua',
['override.metrics.collectors.histogram'] = 'override/metrics/collectors/histogram.lua',
['override.metrics.const'] = 'override/metrics/const.lua',
['override.metrics.plugins.graphite'] = 'override/metrics/plugins/graphite.lua',
['override.metrics.plugins.prometheus'] = 'override/metrics/plugins/prometheus.lua',
['override.metrics.plugins.json'] = 'override/metrics/plugins/json.lua',
['override.metrics.tarantool'] = 'override/metrics/tarantool.lua',
['override.metrics.tarantool.fibers'] = 'override/metrics/tarantool/fibers.lua',
['override.metrics.tarantool.info'] = 'override/metrics/tarantool/info.lua',
['override.metrics.tarantool.memory'] = 'override/metrics/tarantool/memory.lua',
['override.metrics.tarantool.memtx'] = 'override/metrics/tarantool/memtx.lua',
['override.metrics.tarantool.network'] = 'override/metrics/tarantool/network.lua',
['override.metrics.tarantool.operations'] = 'override/metrics/tarantool/operations.lua',
['override.metrics.tarantool.replicas'] = 'override/metrics/tarantool/replicas.lua',
['override.metrics.tarantool.runtime'] = 'override/metrics/tarantool/runtime.lua',
['override.metrics.tarantool.slab'] = 'override/metrics/tarantool/slab.lua',
['override.metrics.tarantool.spaces'] = 'override/metrics/tarantool/spaces.lua',
['override.metrics.tarantool.system'] = 'override/metrics/tarantool/system.lua',
['override.metrics.tarantool.cpu'] = 'override/metrics/tarantool/cpu.lua',
['override.metrics.tarantool.event_loop'] = 'override/metrics/tarantool/event_loop.lua',
['override.metrics.cartridge.issues'] = 'override/metrics/cartridge/issues.lua',
['override.metrics.cartridge.failover'] = 'override/metrics/cartridge/failover.lua',
['override.metrics.tarantool.clock'] = 'override/metrics/tarantool/clock.lua',
['override.metrics.psutils.cpu'] = 'override/metrics/psutils/cpu.lua',
['override.metrics.psutils.psutils_linux'] = 'override/metrics/psutils/psutils_linux.lua',
['override.metrics.tarantool.luajit'] = 'override/metrics/tarantool/luajit.lua',
['override.metrics.tarantool.vinyl'] = 'override/metrics/tarantool/vinyl.lua',
['override.metrics.utils'] = 'override/metrics/utils.lua',
['override.metrics.cfg'] = 'override/metrics/cfg.lua',
['override.metrics.stash'] = 'override/metrics/stash.lua',
['override.metrics.version'] = 'override/metrics/version.lua',
['override.cartridge.roles.metrics'] = 'override/cartridge/roles/metrics.lua',
['override.cartridge.health'] = 'override/cartridge/health.lua',
}
}

Expand Down
1 change: 1 addition & 0 deletions override/cartridge
1 change: 1 addition & 0 deletions override/metrics
4 changes: 4 additions & 0 deletions rpm/tarantool-metrics.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ Easy collecting, storing and manipulating metrics timeseriess.
mkdir -p %{br_luapkgdir}
cp -rv metrics %{br_luapkgdir}
cp -rv cartridge %{br_luapkgdir}
mkdir %{br_luapkgdir}/override
cp -rv metrics %{br_luapkgdir}/override
cp -rv cartridge %{br_luapkgdir}/override

%files
%{luapkgdir}/metrics
%{luapkgdir}/cartridge
%{luapkgdir}/override

%doc README.md
%doc doc/monitoring/getting_started.rst
Expand Down
6 changes: 2 additions & 4 deletions test/helper.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require('strict').on()

-- Clean up built-in metrics to run tests with repository module.
local rock_utils = require('test.rock_utils')
rock_utils.remove_builtin('metrics')
rock_utils.assert_nonbuiltin('metrics')
-- Override should be preferred over built-in.
require('test.rock_utils').assert_nonbuiltin('metrics')


local fio = require('fio')
Expand Down

0 comments on commit 78a47ba

Please sign in to comment.