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.
@@ -1,5 +1,5 @@
1
1
  module Newrelic
2
2
  module Vertica
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -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.class_eval do
10
- add_method_tracer :query, 'Database/Vertica/query'
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic-vertica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: