Skip to content

Commit e655a34

Browse files
yngvar-antonssonvasiliy-t
authored andcommitted
metrics role: collector section removed
1 parent f466e84 commit e655a34

File tree

2 files changed

+17
-82
lines changed

2 files changed

+17
-82
lines changed

cartridge/roles/metrics.lua

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,16 @@ local handlers = {
1414
end,
1515
}
1616

17-
local collectors = {
18-
['tarantool'] = function()
19-
metrics.enable_default_metrics()
20-
end
21-
}
22-
2317
local function init()
24-
assert(argparse.parse())
18+
local params, err = argparse.parse()
19+
assert(params, err)
20+
metrics.set_global_labels({alias = params.alias})
21+
metrics.enable_default_metrics()
2522
end
2623

2724
local function check_config(_)
2825
checks({
2926
export = 'table',
30-
collect = 'table',
3127
})
3228
end
3329

@@ -61,9 +57,6 @@ local function validate_config(conf_new)
6157
assert(paths[v.path] == nil, 'paths must be unique')
6258
paths[v.path] = true
6359
end
64-
for k, _ in pairs(conf_new.collect) do
65-
assert(collectors[k], 'collector must be "tarantool"')
66-
end
6760
return true
6861
end
6962

@@ -79,12 +72,6 @@ local function apply_config(conf)
7972
end
8073
metrics_conf = { collect = {}, export = {} }
8174
end
82-
for name, opts in pairs(metrics_conf.collect) do
83-
collectors[name](opts)
84-
end
85-
86-
local params = argparse.parse()
87-
metrics.set_global_labels({alias = params.alias})
8875

8976
local httpd = cartridge.service_get('httpd')
9077
for _, exporter in ipairs(metrics_conf.export) do

test/integration/cartridge_metrics_test.lua

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ end
3939

4040
g.test_role_enabled = function()
4141
local resp = g.cluster.main_server.net_box:eval([[
42-
local cartridge = require('cartridge')
43-
return cartridge.service_get('metrics') == nil
42+
local cartridge = require('cartridge')
43+
return cartridge.service_get('metrics') == nil
4444
]])
4545
t.assert_equals(resp, false)
4646
end
@@ -55,31 +55,28 @@ g.test_role_add_metrics_http_endpoint = function()
5555
format = 'json'
5656
},
5757
},
58-
collect = {
59-
tarantool = {},
60-
}
6158
}
6259
})
6360
t.assert_equals(resp.status, 200)
6461
g.cluster.main_server.net_box:eval([[
65-
local cartridge = require('cartridge')
66-
local metrics = cartridge.service_get('metrics')
67-
metrics.counter('test-counter'):inc(1)
62+
local cartridge = require('cartridge')
63+
local metrics = cartridge.service_get('metrics')
64+
metrics.counter('test-counter'):inc(1)
6865
]])
6966

7067
local counter_present = false
7168

7269
resp = server:http_request('get', '/metrics', {raise = false})
7370
t.assert_equals(resp.status, 200)
7471
for _, obs in pairs(resp.json) do
75-
t.assert_equals(
76-
g.cluster.main_server.alias, obs.label_pairs['alias'],
77-
('Alias label is present in metric %s'):format(obs.metric_name)
78-
)
79-
if obs.metric_name == 'test-counter' then
80-
counter_present = true
81-
t.assert_equals(obs.value, 1)
82-
end
72+
t.assert_equals(
73+
g.cluster.main_server.alias, obs.label_pairs['alias'],
74+
('Alias label is present in metric %s'):format(obs.metric_name)
75+
)
76+
if obs.metric_name == 'test-counter' then
77+
counter_present = true
78+
t.assert_equals(obs.value, 1)
79+
end
8380
end
8481
t.assert_equals(counter_present, true)
8582

@@ -91,9 +88,6 @@ g.test_role_add_metrics_http_endpoint = function()
9188
format = 'json'
9289
},
9390
},
94-
collect = {
95-
tarantool = {},
96-
}
9791
}
9892
})
9993
t.assert_equals(resp.status, 200)
@@ -113,9 +107,6 @@ g.test_validate_config_invalid_export_section = function()
113107
assert_bad_config({
114108
metrics = {
115109
export = '/metrics',
116-
collect = {
117-
tarantool = {},
118-
}
119110
},
120111
}, 'bad argument')
121112
end
@@ -129,9 +120,6 @@ g.test_validate_config_invalid_export_format = function()
129120
format = 'invalid-format'
130121
},
131122
},
132-
collect = {
133-
tarantool = {},
134-
}
135123
}
136124
}, 'format must be "json" or "prometheus"')
137125
end
@@ -149,9 +137,6 @@ g.test_validate_config_duplicate_paths = function()
149137
format = 'prometheus'
150138
},
151139
},
152-
collect = {
153-
tarantool = {},
154-
}
155140
}
156141
}, 'paths must be unique')
157142

@@ -167,9 +152,6 @@ g.test_validate_config_duplicate_paths = function()
167152
format = 'prometheus'
168153
},
169154
},
170-
collect = {
171-
tarantool = {},
172-
}
173155
}
174156
}, 'paths must be unique')
175157

@@ -185,40 +167,6 @@ g.test_validate_config_duplicate_paths = function()
185167
format = 'prometheus'
186168
},
187169
},
188-
collect = {
189-
tarantool = {},
190-
}
191170
}
192171
}, 'paths must be unique')
193172
end
194-
195-
g.test_validate_config_invalid_collect_section = function()
196-
assert_bad_config({
197-
metrics = {
198-
export = {
199-
{
200-
path = '/metrics',
201-
format = 'json'
202-
},
203-
},
204-
collect = 'tarantool'
205-
}
206-
}, 'bad argument')
207-
end
208-
209-
g.test_validate_config_invalid_collector = function()
210-
assert_bad_config({
211-
metrics = {
212-
export = {
213-
{
214-
path = '/metrics',
215-
format = 'json'
216-
},
217-
},
218-
collect = {
219-
tarantool = {},
220-
invalid_collector = {},
221-
}
222-
}
223-
}, 'collector must be "tarantool"')
224-
end

0 commit comments

Comments
 (0)