]> git.openstreetmap.org Git - chef.git/commitdiff
Improve error handling in API statistics daemon
authorTom Hughes <tom@compton.nu>
Thu, 9 Mar 2023 21:49:23 +0000 (21:49 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 9 Mar 2023 21:49:23 +0000 (21:49 +0000)
cookbooks/web/templates/default/api-statistics.erb

index 297a2ef514f50a3e3a00523b8ab5480b90544958..ce3af0b3430275a258e413236220ea0680dfaa96 100644 (file)
@@ -34,7 +34,7 @@ statistics = {
 
 File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line|
   begin
-    hash = parser.parse(line)
+    hash = parser.parse!(line)
 
     uri = categorise_uri(hash["%r"])
     status = hash["%>s"]
@@ -51,8 +51,8 @@ File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line|
     statistics[:seconds][[uri, status]] += seconds
     statistics[:ssl][[protocol, cipher]] += 1 unless protocol == "-"
     statistics[:auth][auth] += 1 unless auth == "-"
-  rescue ApacheLogRegex::ParseError
-    # nil
+  rescue ApacheLogRegex::ParseError => ex
+    STDERR.puts ex.to_s
   end
 
   if Time.now - last_write > 10