Hi -
>From 135162e03b2939e1fec484d276b9c34364fc566d Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" <f...@redhat.com> Date: Thu, 19 Nov 2020 13:16:10 -0500 Subject: [PATCH] debuginfod: add thread-busy metrics to webapi service Improve monitoring of debuginfod instances by tracking thread_busy status for the threads responding to http requests. While these are usually short-lived, longer archive-uncompress operations can take long enough time to show up on top/uptime. This should also assist noticing abusive clients and guide scaling of the service. Signed-off-by: Frank Ch. Eigler <f...@redhat.com> --- debuginfod/ChangeLog | 5 +++++ debuginfod/debuginfod.cxx | 17 +++++++++++++++++ tests/ChangeLog | 4 ++++ tests/run-debuginfod-find.sh | 3 +++ 4 files changed, 29 insertions(+) diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index a02643e17b7d..d480f67549be 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2020-11-19 Frank Ch. Eigler <f...@redhat.com> + + * debuginfod.cxx (tmp_inc_metric): New class. + (handler_cb): Use it to track webapi operations. + 2020-11-01 Ãrico N. Rolim <erico....@gmail.com> * debuginfod-client.c (debuginfod_init_cache): Use ACCESSPERMS for diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index d2a434eebb8d..78e2a4307f81 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -421,6 +421,21 @@ static void add_metric(const string& metric, int64_t value); // static void add_metric(const string& metric, int64_t value); +class tmp_inc_metric { // a RAII style wrapper for exception-safe scoped increment & decrement + string m, n, v; +public: + tmp_inc_metric(const string& mname, const string& lname, const string& lvalue): + m(mname), n(lname), v(lvalue) + { + add_metric (m, n, v, 1); + } + ~tmp_inc_metric() + { + add_metric (m, n, v, -1); + } +}; + + /* Handle program arguments. */ static error_t parse_opt (int key, char *arg, @@ -1823,6 +1838,7 @@ handler_cb (void * /*cls*/, if (slash1 != string::npos && url1 == "/buildid") { + tmp_inc_metric m ("thread_busy", "role", "http-buildid"); size_t slash2 = url_copy.find('/', slash1+1); if (slash2 == string::npos) throw reportable_exception("/buildid/ webapi error, need buildid"); @@ -1856,6 +1872,7 @@ handler_cb (void * /*cls*/, } else if (url1 == "/metrics") { + tmp_inc_metric m ("thread_busy", "role", "http-metrics"); inc_metric("http_requests_total", "type", "metrics"); r = handle_metrics(& http_size); } diff --git a/tests/ChangeLog b/tests/ChangeLog index f7b78c83fb79..f9a47023349d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2020-11-19 Frank Ch. Eigler <f...@redhat.com> + + * run-debuginfod-find.sh: Look for http-* metrics. + 2020-11-01 Ãrico N. Rolim <erico....@gmail.com> Mark Wielaard <m...@klomp.org> diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh index 48dbc7d4edf4..2533f08ef772 100755 --- a/tests/run-debuginfod-find.sh +++ b/tests/run-debuginfod-find.sh @@ -410,6 +410,9 @@ wait_ready $PORT2 'thread_work_total{role="traverse"}' 1 wait_ready $PORT2 'thread_work_pending{role="scan"}' 0 wait_ready $PORT2 'thread_busy{role="scan"}' 0 +wait_ready $PORT2 'thread_busy{role="http-buildid"}' 0 +wait_ready $PORT2 'thread_busy{role="http-metrics"}' 1 + # have clients contact the new server export DEBUGINFOD_URLS=http://127.0.0.1:$PORT2 -- 2.28.0