]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: add thread-busy metrics to webapi service
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 19 Nov 2020 18:16:10 +0000 (13:16 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Sat, 21 Nov 2020 22:10:49 +0000 (17:10 -0500)
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 <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx
tests/ChangeLog
tests/run-debuginfod-find.sh

index d4face2d1c3fb28a9c5c7215b806c4549c6c122f..34e07793adf10940054ef87227b9767349ea403d 100644 (file)
@@ -3,6 +3,11 @@
        * debuginfod-find.c (progressfn): Use clock_gettime to print Progress
        at most 5 times a second.
 
+2020-11-19  Frank Ch. Eigler  <fche@redhat.com>
+
+       * debuginfod.cxx (tmp_inc_metric): New class.
+       (handler_cb): Use it to track webapi operations.
+
 2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
 
        * debuginfod-client.c (debuginfod_init_cache): Use ACCESSPERMS for
index d2a434eebb8d2050f77610288658883c6faef4f5..78e2a4307f81b167852a4279fd94fbe5a1eb6ffd 100644 (file)
@@ -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);
         }
index 94686137613a2cd9dc65fafb66d7229e6fc665a2..c130ce049caae5c34ef4a887982c54039320adc3 100644 (file)
@@ -3,6 +3,10 @@
        * run-debuginfod-find.sh: Create bogus R/nothing.rpm with cyclic
        symlink instead of chmod 000.
 
+2020-11-19  Frank Ch. Eigler  <fche@redhat.com>
+
+       * run-debuginfod-find.sh: Look for http-* metrics.
+
 2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
            Mark Wielaard  <mark@klomp.org>
 
index 5af456674727d235c7c1ff94cdfdb2e4346414d8..28aa4263c50010de28b4def67cb50e9363bd8d36 100755 (executable)
@@ -411,6 +411,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