newrelic-vertica 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/newrelic-vertica/version.rb +1 -1
- data/lib/newrelic-vertica/vertica.rb +34 -4
- metadata +1 -1
@@ -1,14 +1,44 @@
|
|
1
1
|
require 'new_relic/agent/method_tracer'
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
module NewRelic
|
5
|
+
module Agent
|
6
|
+
module Instrumentation
|
7
|
+
module VerticaInstrumentation
|
8
|
+
|
9
|
+
def self.included(klass)
|
10
|
+
klass.class_eval do
|
11
|
+
alias_method :query_without_instrumentation, :query
|
12
|
+
alias_method :query, :query_with_instrumentation
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def query_with_instrumentation(sql, options = {}, &block)
|
17
|
+
result = nil
|
18
|
+
duration = Benchmark.realtime do
|
19
|
+
result = query_without_instrumentation(sql, options, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
if NewRelic::Agent.is_execution_traced?
|
23
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, nil, duration)
|
24
|
+
end
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
2
32
|
|
3
33
|
DependencyDetection.defer do
|
4
34
|
depends_on do
|
5
|
-
defined?(::Vertica)
|
35
|
+
defined?(::Vertica) && defined?(::Vertica::Connection)
|
6
36
|
end
|
7
37
|
|
8
38
|
executes do
|
9
|
-
::Vertica::Connection.
|
10
|
-
|
11
|
-
add_method_tracer :copy, 'Database/Vertica/copy'
|
39
|
+
::Vertica::Connection.instance_eval do
|
40
|
+
include ::NewRelic::Agent::Instrumentation::VerticaInstrumentation
|
12
41
|
end
|
13
42
|
end
|
14
43
|
end
|
44
|
+
|