Correct syntax that was not working on Ruby 2.4 and below

approved
#1

Correct syntax that was not working on Ruby 2.4 and below

diff --git a/lib/prometheus_exporter/instrumentation/unicorn.rb b/lib/prometheus_exporter/instrumentation/unicorn.rb
index d0b5413..e5ee3e1 100644
--- a/lib/prometheus_exporter/instrumentation/unicorn.rb
+++ b/lib/prometheus_exporter/instrumentation/unicorn.rb
@@ -12,12 +12,14 @@ module PrometheusExporter::Instrumentation
       client ||= PrometheusExporter::Client.default
       Thread.new do
         loop do
-          metric = unicorn_collector.collect
-          client.send_json metric
-        rescue StandardError => e
-          STDERR.puts("Prometheus Exporter Failed To Collect Unicorn Stats #{e}")
-        ensure
-          sleep frequency
+          begin
+            metric = unicorn_collector.collect
+            client.send_json metric
+          rescue StandardError => e
+            STDERR.puts("Prometheus Exporter Failed To Collect Unicorn Stats #{e}")
+          ensure
+            sleep frequency
+          end
         end
       end
     end

GitHub sha: 834e7d2a

Approved #2