aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-02 22:16:20 +0100
committerKim Alvefur <zash@zash.se>2021-02-02 22:16:20 +0100
commitf539be51b3e4ca30f223d5064db59133dba32c7c (patch)
treeafebe0010304273133132db66142aaf5a85f0d4b
parente2ea04d9051ff03195d7d36aa4f2e4433bb75574 (diff)
downloadprosody-f539be51b3e4ca30f223d5064db59133dba32c7c.tar.gz
prosody-f539be51b3e4ca30f223d5064db59133dba32c7c.zip
mod_http_file_share: Collect cache hit/miss statistics for downloads
-rw-r--r--plugins/mod_http_file_share.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua
index 9b933b25..01f204eb 100644
--- a/plugins/mod_http_file_share.lua
+++ b/plugins/mod_http_file_share.lua
@@ -274,6 +274,9 @@ function handle_upload(event, path) -- PUT /upload/:slot
end
+local download_cache_hit = module:measure("download_cache_hit", "rate");
+local download_cache_miss = module:measure("download_cache_miss", "rate");
+
function handle_download(event, path) -- GET /uploads/:slot+filename
local request, response = event.request, event.response;
local slot_id = path:match("^[^/]+");
@@ -281,7 +284,7 @@ function handle_download(event, path) -- GET /uploads/:slot+filename
local cached = upload_cache:get(slot_id);
if cached then
module:log("debug", "Cache hit");
- -- TODO stats (instead of logging?)
+ download_cache_hit();
basename = cached.name;
filesize = cached.size;
filetype = cached.type;
@@ -290,6 +293,7 @@ function handle_download(event, path) -- GET /uploads/:slot+filename
-- TODO cache negative hits?
else
module:log("debug", "Cache miss");
+ download_cache_miss();
local slot, when = errors.coerce(uploads:get(nil, slot_id));
if not slot then
module:log("debug", "uploads:get(%q) --> not-found, %s", slot_id, when);