Comparison

core/moduleapi.lua @ 8994:f17e768c1a99

moduleapi: Lazy-load statsmanager on demand
author Kim Alvefur <zash@zash.se>
date Sat, 07 Jul 2018 21:55:18 +0200
parent 8993:bd9b67f742c9
child 9042:734ba7080b35
comparison
equal deleted inserted replaced
8993:bd9b67f742c9 8994:f17e768c1a99
11 local it = require "util.iterators"; 11 local it = require "util.iterators";
12 local logger = require "util.logger"; 12 local logger = require "util.logger";
13 local pluginloader = require "util.pluginloader"; 13 local pluginloader = require "util.pluginloader";
14 local timer = require "util.timer"; 14 local timer = require "util.timer";
15 local resolve_relative_path = require"util.paths".resolve_relative_path; 15 local resolve_relative_path = require"util.paths".resolve_relative_path;
16 local measure = require "core.statsmanager".measure;
17 local st = require "util.stanza"; 16 local st = require "util.stanza";
18 17
19 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; 18 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat;
20 local error, setmetatable, type = error, setmetatable, type; 19 local error, setmetatable, type = error, setmetatable, type;
21 local ipairs, pairs, select = ipairs, pairs, select; 20 local ipairs, pairs, select = ipairs, pairs, select;
409 function api:open_store(name, store_type) 408 function api:open_store(name, store_type)
410 return require"core.storagemanager".open(self.host, name or self.name, store_type); 409 return require"core.storagemanager".open(self.host, name or self.name, store_type);
411 end 410 end
412 411
413 function api:measure(name, stat_type) 412 function api:measure(name, stat_type)
413 local measure = require "core.statsmanager".measure;
414 return measure(stat_type, "/"..self.host.."/mod_"..self.name.."/"..name); 414 return measure(stat_type, "/"..self.host.."/mod_"..self.name.."/"..name);
415 end 415 end
416 416
417 function api:measure_object_event(events_object, event_name, stat_name) 417 function api:measure_object_event(events_object, event_name, stat_name)
418 local m = self:measure(stat_name or event_name, "times"); 418 local m = self:measure(stat_name or event_name, "times");