Software /
code /
prosody
Annotate
core/statsmanager.lua @ 8706:e2919978673e
net.http: Fix parameter order to http request callbacks
Commit e3b9dc9dd940 changed the parameter order in 2013, but did not update the names of the parameters in the callback function. Due to this inconsistency, 12df41a5a4b1 accidentally reversed the order when fixing the variable names without fixing where they are used.
Additionally the documentation was incorrect (since 2013), and this has also now been fixed.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 04 Apr 2018 18:27:44 +0100 |
parent | 7664:4f145a9f1477 |
child | 9804:7929e0fe0577 |
rev | line source |
---|---|
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local config = require "core.configmanager"; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local log = require "util.logger".init("stats"); |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local timer = require "util.timer"; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local fire_event = prosody.events.fire_event; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 |
7533
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
7 local stats_interval_config = config.get("*", "statistics_interval"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
8 local stats_interval = tonumber(stats_interval_config); |
7664
4f145a9f1477
core.statsmanager: Use correct variable for config validation [luacheck]
Kim Alvefur <zash@zash.se>
parents:
7533
diff
changeset
|
9 if stats_interval_config and not stats_interval then |
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 log("error", "Invalid 'statistics_interval' setting, statistics will be disabled"); |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 end |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
7533
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
13 local stats_provider_name; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
14 local stats_provider_config = config.get("*", "statistics"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
15 local stats_provider = stats_provider_config; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
16 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
17 if not stats_provider and stats_interval then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
18 stats_provider = "internal"; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
19 elseif stats_provider and not stats_interval then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
20 stats_interval = 60; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
21 end |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
22 |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
23 local builtin_providers = { |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
24 internal = "util.statistics"; |
7522
ebf2e77ac8a7
statsmanager, util.statsd: Add built-in statsd provider
Matthew Wild <mwild1@gmail.com>
parents:
7521
diff
changeset
|
25 statsd = "util.statsd"; |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
26 }; |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
27 |
7533
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
28 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
29 local stats, stats_err = false, nil; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
30 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
31 if stats_provider then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
32 if stats_provider:sub(1,1) == ":" then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
33 stats_provider = stats_provider:sub(2); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
34 stats_provider_name = "external "..stats_provider; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
35 elseif stats_provider then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
36 stats_provider_name = "built-in "..stats_provider; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
37 stats_provider = builtin_providers[stats_provider]; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
38 if not stats_provider then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
39 log("error", "Unrecognized statistics provider '%s', statistics will be disabled", stats_provider_config); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
40 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
41 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
42 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
43 local have_stats_provider, stats_lib = pcall(require, stats_provider); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
44 if not have_stats_provider then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
45 stats, stats_err = nil, stats_lib; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
46 else |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
47 local stats_config = config.get("*", "statistics_config"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
48 stats, stats_err = stats_lib.new(stats_config); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
49 stats_provider_name = stats_lib._NAME or stats_provider_name; |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
50 end |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
51 end |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
52 |
7533
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
53 if stats == nil then |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
54 log("error", "Error loading statistics provider '%s': %s", stats_provider, stats_err); |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
55 end |
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
56 |
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 local measure, collect; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 local latest_stats = {}; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 local changed_stats = {}; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 local stats_extra = {}; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
62 if stats then |
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 function measure(type, name) |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 local f = assert(stats[type], "unknown stat type: "..type); |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 return f(name); |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 end |
7533
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
67 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
68 if stats_interval then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
69 log("debug", "Statistics enabled using %s provider, collecting every %d seconds", stats_provider_name, stats_interval); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
70 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
71 local mark_collection_start = measure("times", "stats.collection"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
72 local mark_processing_start = measure("times", "stats.processing"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
73 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
74 function collect() |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
75 local mark_collection_done = mark_collection_start(); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
76 fire_event("stats-update"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
77 mark_collection_done(); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
78 |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
79 if stats.get_stats then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
80 changed_stats, stats_extra = {}, {}; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
81 for stat_name, getter in pairs(stats.get_stats()) do |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
82 local type, value, extra = getter(); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
83 local old_value = latest_stats[stat_name]; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
84 latest_stats[stat_name] = value; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
85 if value ~= old_value then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
86 changed_stats[stat_name] = value; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
87 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
88 if extra then |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
89 stats_extra[stat_name] = extra; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
90 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
91 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
92 local mark_processing_done = mark_processing_start(); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
93 fire_event("stats-updated", { stats = latest_stats, changed_stats = changed_stats, stats_extra = stats_extra }); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
94 mark_processing_done(); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
95 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
96 return stats_interval; |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
97 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
98 timer.add_task(stats_interval, collect); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
99 prosody.events.add_handler("server-started", function () collect() end, -1); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
100 else |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
101 log("debug", "Statistics enabled using %s provider, collection is disabled", stats_provider_name); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
102 end |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
103 else |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
104 log("debug", "Statistics disabled"); |
4ef37ac69562
statsmanager: Refactor to simplify logic. Notably renames 'statistics_provider' to 'statistics', and external libs now just begin with ':'
Matthew Wild <mwild1@gmail.com>
parents:
7524
diff
changeset
|
105 function measure() return measure; end |
7521
1c8b63fe6472
statsmanager: Add 'stats_provider' option, to allow selecting alternative API providers to util.statistics
Matthew Wild <mwild1@gmail.com>
parents:
6910
diff
changeset
|
106 end |
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 return { |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 measure = measure; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 get_stats = function () |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 return latest_stats, changed_stats, stats_extra; |
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 end; |
6910
82765a4ec799
statsmanager: Add get() method
Matthew Wild <mwild1@gmail.com>
parents:
6582
diff
changeset
|
114 get = function (name) |
82765a4ec799
statsmanager: Add get() method
Matthew Wild <mwild1@gmail.com>
parents:
6582
diff
changeset
|
115 return latest_stats[name], stats_extra[name]; |
82765a4ec799
statsmanager: Add get() method
Matthew Wild <mwild1@gmail.com>
parents:
6582
diff
changeset
|
116 end; |
6554
6c22bec3e8d0
statsmanager, prosody: New core module and API for gathering statistics about the running server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 }; |