]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
docker: measure request resolution time in debug mode
authorPetr Špaček <petr.spacek@nic.cz>
Mon, 27 Apr 2020 06:13:57 +0000 (08:13 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Mon, 27 Apr 2020 13:39:38 +0000 (15:39 +0200)
etc/config/config.docker

index 9f27c9341569c90d2279894ce52834373dac88af..8e82a6098f0d0093efb426aa5234303739af5e67 100644 (file)
@@ -55,12 +55,15 @@ function debug_mode(qname, qtype)
        -- always empty cache so this config works reliably outside Docker
        cache.clear()
 
+       local cqueues = require('cqueues')
+
        -- execute query right after start up and exit when the query is finished
        event.after(0, function()
                -- ultra verbose log
                verbose(true)
                policy.add(policy.all(policy.DEBUG_ALWAYS))
-               log('INFO: starting your DNS query for %s %s, verbose log follows', qname, kres.tostring.type[qtype])
+               log('INFO: starting DNS query for %s %s', qname, kres.tostring.type[qtype])
+               local starttime = cqueues.monotime()
                resolve({
                        name = qname,
                        type = qtype,
@@ -70,6 +73,8 @@ function debug_mode(qname, qtype)
                                -- to prevent us from losing policy.DEBUG finish callback
                                event.after(1, -- milisecond
                                        function()
+                                               local endtime = cqueues.monotime()
+                                               log('\nrequest finished in %f ms', (endtime - starttime) * 1000)
                                                os.exit()
                                        end)
                                end