.luacheckrc
author Jonas Schäfer <jonas@wielicki.name>
Sun, 18 Apr 2021 11:47:41 +0200
changeset 11527 5f15ab7c6ae5
parent 11439 a1fa6202fa13
child 11991 4b519c575ad0
permissions -rw-r--r--
Statistics: Rewrite statistics backends to use OpenMetrics The metric subsystem of Prosody has had some shortcomings from the perspective of the current state-of-the-art in metric observability. The OpenMetrics standard [0] is a formalization of the data model (and serialization format) of the well-known and widely-used Prometheus [1] software stack. The previous stats subsystem of Prosody did not map well to that format (see e.g. [2] and [3]); the key reason is that it was trying to do too much math on its own ([2]) while lacking first-class support for "families" of metrics ([3]) and structured metric metadata (despite the `extra` argument to metrics, there was no standard way of representing common things like "tags" or "labels"). Even though OpenMetrics has grown from the Prometheus world of monitoring, it maps well to other popular monitoring stacks such as: - InfluxDB (labels can be mapped to tags and fields as necessary) - Carbon/Graphite (labels can be attached to the metric name with dot-separation) - StatsD (see graphite when assuming that graphite is used as backend, which is the default) The util.statsd module has been ported to use the OpenMetrics model as a proof of concept. An implementation which exposes the util.statistics backend data as Prometheus metrics is ready for publishing in prosody-modules (most likely as mod_openmetrics_prometheus to avoid breaking existing 0.11 deployments). At the same time, the previous measure()-based API had one major advantage: It is really simple and easy to use without requiring lots of knowledge about OpenMetrics or similar concepts. For that reason as well as compatibility with existing code, it is preserved and may even be extended in the future. However, code relying on the `stats-updated` event as well as `get_stats` from `statsmanager` will break because the data model has changed completely; in case of `stats-updated`, the code will simply not run (as the event was renamed in order to avoid conflicts); the `get_stats` function has been removed completely (so it will cause a traceback when it is attempted to be used). Note that the measure_*_event methods have been removed from the module API. I was unable to find any uses or documentation and thus deemed they should not be ported. Re-implementation is possible when necessary. [0]: https://openmetrics.io/ [1]: https://prometheus.io/ [2]: #959 [3]: #960

cache = true
codes = true
ignore = { "411/err", "421/err", "411/ok", "421/ok", "211/_ENV", "431/log", }

std = "lua53c"
max_line_length = 150

read_globals = {
	"prosody",
	"import",
};
files["prosody"] = {
	allow_defined_top = true;
	module = true;
}
files["prosodyctl"] = {
	allow_defined_top = true;
	module = true;
};
files["core/"] = {
	globals = {
		"prosody.hosts.?",
	};
}
files["util/"] = {
	-- Ignore unwrapped license text
	max_comment_line_length = false;
}
files["util/jsonschema.lua"] = {
	ignore = { "211" };
}
files["util/datamapper.lua"] = {
	ignore = { "211" };
}
files["plugins/"] = {
	module = true;
	allow_defined_top = true;
	read_globals = {
		-- Module instance
		"module.name",
		"module.host",
		"module._log",
		"module.event_handlers",
		"module.reloading",
		"module.saved_state",
		"module.global",
		"module.path",

		-- Module API
		"module.add_extension",
		"module.add_feature",
		"module.add_identity",
		"module.add_item",
		"module.add_timer",
		"module.broadcast",
		"module.context",
		"module.depends",
		"module.fire_event",
		"module.get_directory",
		"module.get_host",
		"module.get_host_items",
		"module.get_host_type",
		"module.get_name",
		"module.get_option",
		"module.get_option_array",
		"module.get_option_boolean",
		"module.get_option_inherited_set",
		"module.get_option_number",
		"module.get_option_path",
		"module.get_option_scalar",
		"module.get_option_set",
		"module.get_option_string",
		"module.get_status",
		"module.handle_items",
		"module.hook",
		"module.hook_global",
		"module.hook_object_event",
		"module.hook_tag",
		"module.load_resource",
		"module.log",
		"module.log_status",
		"module.measure",
		"module.metric",
		"module.open_store",
		"module.provides",
		"module.remove_item",
		"module.require",
		"module.send",
		"module.send_iq",
		"module.set_global",
		"module.set_status",
		"module.shared",
		"module.unhook",
		"module.unhook_object_event",
		"module.wrap_event",
		"module.wrap_global",
		"module.wrap_object_event",

		-- mod_http API
		"module.http_url",
	};
	globals = {
		-- Methods that can be set on module API
		"module.unload",
		"module.add_host",
		"module.load",
		"module.add_host",
		"module.save",
		"module.restore",
		"module.command",
		"module.environment",
	};
}
files["spec/"] = {
	std = "+busted";
	globals = { "randomize" };
}
files["prosody.cfg.lua"] = {
	ignore = { "131" };
	globals = {
		"Host",
		"host",
		"VirtualHost",
		"Component",
		"component",
		"Include",
		"include",
		"RunScript"
	};
}

if os.getenv("PROSODY_STRICT_LINT") ~= "1" then
	-- These files have not yet been brought up to standard
	-- Do not add more files here, but do help us fix these!

	local exclude_files = {
		"doc/net.server.lua";

		"fallbacks/bit.lua";
		"fallbacks/lxp.lua";

		"net/dns.lua";
		"net/server_select.lua";

		"plugins/mod_storage_sql1.lua";

		"spec/core_moduleapi_spec.lua";
		"spec/util_http_spec.lua";
		"spec/util_ip_spec.lua";
		"spec/util_multitable_spec.lua";
		"spec/util_rfc6724_spec.lua";
		"spec/util_throttle_spec.lua";

		"tools/ejabberd2prosody.lua";
		"tools/ejabberdsql2prosody.lua";
		"tools/erlparse.lua";
		"tools/jabberd14sql2prosody.lua";
		"tools/migration/migrator.cfg.lua";
		"tools/migration/migrator/jabberd14.lua";
		"tools/migration/migrator/mtools.lua";
		"tools/migration/migrator/prosody_files.lua";
		"tools/migration/migrator/prosody_sql.lua";
		"tools/migration/prosody-migrator.lua";
		"tools/openfire2prosody.lua";
		"tools/xep227toprosody.lua";
	}
	for _, file in ipairs(exclude_files) do
		files[file] = { only = {} }
	end
end