Mercurial > prosody-modules
comparison mod_http_admin_api/mod_http_admin_api.lua @ 5827:f76909ec1300
mod_http_admin_api: metrics: Filter out a value that is commonly nan at startup
The upload bytes count is typically nan at startup, which cannot legally be
encoded in JSON.
I haven't assessed whether any other metrics might emit nan under other
circumstances, but this fixes the most visible issue right now.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 13 Jan 2024 12:03:15 +0000 |
parents | 076b79eb747f |
children | 9f2816287556 |
comparison
equal
deleted
inserted
replaced
5826:791aa8072f58 | 5827:f76909ec1300 |
---|---|
746 end | 746 end |
747 local sum = 0; | 747 local sum = 0; |
748 for _, metric in mf:iter_metrics() do | 748 for _, metric in mf:iter_metrics() do |
749 sum = sum + metric.value; | 749 sum = sum + metric.value; |
750 end | 750 end |
751 return sum; | 751 return (sum == sum) and sum or nil; -- Filter out nan |
752 end | 752 end |
753 | 753 |
754 local function get_server_metrics(event) | 754 local function get_server_metrics(event) |
755 event.response.headers["Content-Type"] = json_content_type; | 755 event.response.headers["Content-Type"] = json_content_type; |
756 local result = {}; | 756 local result = {}; |