public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Frank Ch. Eigler" <fche@redhat.com>
To: elfutils-devel@sourceware.org
Subject: [patch] debuginfod more metrics
Date: Thu, 19 Nov 2020 13:50:02 -0500	[thread overview]
Message-ID: <20201119185002.GA29564@redhat.com> (raw)

Hi -


From 135162e03b2939e1fec484d276b9c34364fc566d Mon Sep 17 00:00:00 2001
From: "Frank Ch. Eigler" <fche@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 <fche@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  <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
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  <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>
 
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


             reply	other threads:[~2020-11-19 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 18:50 Frank Ch. Eigler [this message]
2020-11-21 15:52 ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201119185002.GA29564@redhat.com \
    --to=fche@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).