MySQL2 support (#44)

MySQL2 support (#44)

Fixes #18

From 2cc4eb504a55612f6476bc1ba4072a2daf390773 Mon Sep 17 00:00:00 2001
From: andrew morton <drewish@katherinehouse.com>
Date: Sun, 11 Nov 2018 15:35:34 -0700
Subject: [PATCH] MySQL2 support (#44)

Fixes #18

diff --git a/lib/prometheus_exporter/middleware.rb b/lib/prometheus_exporter/middleware.rb
index 4f11313..d068d71 100644
--- a/lib/prometheus_exporter/middleware.rb
+++ b/lib/prometheus_exporter/middleware.rb
@@ -19,6 +19,11 @@ class PrometheusExporter::Middleware
           :exec, :async_exec, :exec_prepared, :send_query_prepared, :query
         ], :sql)
       end
+      if defined? Mysql2::Client
+        MethodProfiler.patch(Mysql2::Client, [:query], :sql)
+        MethodProfiler.patch(Mysql2::Statement, [:execute], :sql)
+        MethodProfiler.patch(Mysql2::Result, [:each], :sql)
+      end
     end
   end

GitHub