]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
PR25448: debuginfod: add transfer performance metrics
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 26 Mar 2020 20:44:20 +0000 (16:44 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Fri, 27 Mar 2020 14:55:50 +0000 (10:55 -0400)
We now export metrics related to the time taken and data sent,
from which prometheus type tools can compute nice time series
with averages.

http_responses_duration_milliseconds_count{code="200"} 63
http_responses_duration_milliseconds_count{code="404"} 2
http_responses_duration_milliseconds_count{code="503"} 1
http_responses_duration_milliseconds_sum{code="200"} 66
http_responses_duration_milliseconds_sum{code="404"} 2
http_responses_duration_milliseconds_sum{code="503"} 0
http_responses_transfer_bytes_count{code="200"} 63
http_responses_transfer_bytes_count{code="404"} 2
http_responses_transfer_bytes_count{code="503"} 1
http_responses_transfer_bytes_sum{code="200"} 425177
http_responses_transfer_bytes_sum{code="404"} 18
http_responses_transfer_bytes_sum{code="503"} 37

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx
tests/ChangeLog
tests/run-debuginfod-find.sh

index 58ba85cf36649097e4184f1146c22d919435dabc..989a90295459b53fb636b7d19562de044b7fafd4 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-26  Frank Ch. Eigler <fche@redhat.com>
+
+       * debuginfod.cxx (handler_cb): Export two families of metrics for
+       prometheus traffic analysis: response times and data amounts.
+
 2020-03-26  Frank Ch. Eigler <fche@redhat.com>
 
        * debuginfod.cxx (parse_opt): For -U, prefer dpkg-deb
index 9e8d55609c56be188b1894c08faf5e5ccb99c37c..98491c2c6e3c1c52f82460458dafdc64e8889905 100644 (file)
@@ -1767,6 +1767,7 @@ handler_cb (void * /*cls*/,
       inc_metric("http_responses_total","result","error");
       e.report(clog);
       http_code = e.code;
+      http_size = e.message.size();
       rc = e.mhd_send_response (connection);
     }
 
@@ -1778,6 +1779,17 @@ handler_cb (void * /*cls*/,
                  << ' ' << (int)(deltas*1000) << "ms"
                  << endl;
 
+  // related prometheus metrics
+  string http_code_str = to_string(http_code);
+  if (http_size >= 0)
+    add_metric("http_responses_transfer_bytes_sum","code",http_code_str,
+               http_size);
+  inc_metric("http_responses_transfer_bytes_count","code",http_code_str);
+
+  add_metric("http_responses_duration_milliseconds_sum","code",http_code_str,
+             deltas*1000); // prometheus prefers _seconds and floating point
+  inc_metric("http_responses_duration_milliseconds_count","code",http_code_str);
+
   return rc;
 }
 
index c06d892440a0da186ae9237575f11f663be2dfee..ba88ecf6aeb9d3cb7841c544bd24aebf18169450 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-26  Frank Ch. Eigler <fche@redhat.com>
+
+       * run-debuginfod-find.sh: Look for debuginfod's new
+       http_responses_* metrics.
+
 2020-03-26  Frank Ch. Eigler <fche@redhat.com>
 
        * run-debuginfod-find.sh: Look for bsdtar instead of dpkg.
index cc826f9607a4798ff364631d6c46e34c9dc8152b..db36420f75ecbec0ec4b46d6dbf0fbf36ffe6d86 100755 (executable)
@@ -416,6 +416,10 @@ curl -s http://127.0.0.1:$PORT2/metrics
 curl -s http://127.0.0.1:$PORT1/metrics | grep -q 'http_responses_total.*result.*error'
 curl -s http://127.0.0.1:$PORT1/metrics | grep -q 'http_responses_total.*result.*fdcache'
 curl -s http://127.0.0.1:$PORT2/metrics | grep -q 'http_responses_total.*result.*upstream'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_duration_milliseconds_count'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_duration_milliseconds_sum'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_count'
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'http_responses_transfer_bytes_sum'
 
 # And generate a few errors into the second debuginfod's logs, for analysis just below
 curl -s http://127.0.0.1:$PORT2/badapi > /dev/null || true