* [patch] debuginfod more metrics
@ 2020-11-19 18:50 Frank Ch. Eigler
2020-11-21 15:52 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Frank Ch. Eigler @ 2020-11-19 18:50 UTC (permalink / raw)
To: elfutils-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] debuginfod more metrics
2020-11-19 18:50 [patch] debuginfod more metrics Frank Ch. Eigler
@ 2020-11-21 15:52 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2020-11-21 15:52 UTC (permalink / raw)
To: Frank Ch. Eigler, elfutils-devel
Hi Frank,
On Thu, 2020-11-19 at 13:50 -0500, Frank Ch. Eigler via Elfutils-devel
wrote:
> 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.
Looks fine to me. The scoped increment & decrement is nice.
Cheers,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-21 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 18:50 [patch] debuginfod more metrics Frank Ch. Eigler
2020-11-21 15:52 ` Mark Wielaard
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).