dolores_rpm 3.2.0.3 → 3.2.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
+ v3.2.0.4
2
+ * Trying revised version of DataMapper support from NewRelic HEAD
3
+
1
4
  v3.2.0.3
2
- * Slightly newer DataMapper support
5
+ * Upgraded DataMapper support but it didn't work
3
6
 
4
7
  v3.2.0.2
5
8
  * Roll back to previous version of DataMapper instrumentation (current one does not work for our app)
Binary file
data/dolores_rpm.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dolores_rpm"
8
- s.version = "3.2.0.3"
8
+ s.version = "3.2.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
12
- s.date = "2012-05-02"
12
+ s.date = "2012-05-04"
13
13
  s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). This is a fork that uses an older version\nof the DataMapper instrumentation. Newer versions did not work for us.\n"
14
14
  s.email = "support@newrelic.com"
15
15
  s.executables = ["newrelic_cmd", "newrelic", "mongrel_rpm"]
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "cert/cacert.pem",
30
30
  "cert/oldsite.pem",
31
31
  "cert/site.pem",
32
+ "dolores_rpm-3.2.0.3.gem",
32
33
  "dolores_rpm.gemspec",
33
34
  "install.rb",
34
35
  "lib/conditional_vendored_dependency_detection.rb",
@@ -1,47 +1,7 @@
1
- ## NewRelic instrumentation for DataMapper
2
- #
3
- # Instrumenting DM has different key challenges versus AR:
4
- #
5
- # 1. The hooking of SQL logging in DM is decoupled from any knowledge of the
6
- # Model#method that invoked it. But on the positive side, the duration is
7
- # already calculated for you (and it happens inside the C-based DO code, so
8
- # it's faster than a Ruby equivalent).
9
- #
10
- # 2. There are a lot more entry points that need to be hooked in order to
11
- # understand call flow: DM::Model (model class) vs. DM::Resource (model
12
- # instance) vs. DM::Collection (collection of model instances). And
13
- # others.
14
- #
15
- # 3. Strategic Eager Loading (SEL) combined with separately-grouped
16
- # lazy-loaded attributes presents a unique problem for tying resulting
17
- # SEL-invoked SQL calls to their proper scope.
18
- #
19
- # NOTE: On using "Database" versus "ActiveRecord" as base metric name
20
- #
21
- # Using "Database" as the metric name base seems to properly identify methods
22
- # as being DB-related in call graphs, but certain RPM views that show
23
- # aggregations of DB CPM, etc still seem to rely solely on "ActiveRecord"
24
- # being the base name, thus AFAICT "Database" calls to this are lost. (Though
25
- # I haven't yet tested "Database/SQL/{find/save/destroy/all}" yet, as it seems
26
- # like an intuitively good name to use.)
27
- #
28
- # So far I think these are the rules:
29
- #
30
- # - ActiveRecord/{find/save/destroy} populates "Database Throughput" and
31
- # "Database Response Time" in the Database tab. [non-scoped]
32
- #
33
- # - ActiveRecord/all populates the main Overview tab of DB time. (still
34
- # unsure about this one). [non-scoped]
35
- #
36
- # These metrics are represented as :push_scope => false or included as the
37
- # non-first metric in trace_execution_scoped() (docs say only first counts
38
- # towards scope) so they don't show up ine normal call graph/trace.
39
-
40
- if defined? ::DataMapper
41
-
42
- # DM::Model class methods
43
- ::DataMapper::Model.class_eval do
44
-
1
+ # NewRelic instrumentation for DataMapper
2
+ # For now, we have to refer to all db metrics as "ActiveRecord"
3
+ if defined? DataMapper
4
+ DataMapper::Model.class_eval do
45
5
  add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
46
6
  add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
47
7
  add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
@@ -59,24 +19,18 @@ if defined? ::DataMapper
59
19
  next unless method_defined? method
60
20
  add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
61
21
  end
62
-
63
22
  end
64
23
 
65
- # DM's Model instance (Resource) methods
66
- ::DataMapper::Resource.class_eval do
67
-
24
+ DataMapper::Resource.class_eval do
68
25
  add_method_tracer :update, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
69
26
  add_method_tracer :update!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/update'
70
27
  add_method_tracer :save, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
71
28
  add_method_tracer :save!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
72
29
  add_method_tracer :destroy, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
73
30
  add_method_tracer :destroy!, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
74
-
75
31
  end
76
32
 
77
- # DM's Collection instance methods
78
- ::DataMapper::Collection.class_eval do
79
-
33
+ DataMapper::Collection.class_eval do
80
34
  add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
81
35
  add_method_tracer :first, 'ActiveRecord/#{self.name}/first'
82
36
  add_method_tracer :last, 'ActiveRecord/#{self.name}/last'
@@ -96,86 +50,67 @@ if defined? ::DataMapper
96
50
  next unless method_defined? method
97
51
  add_method_tracer(method, 'ActiveRecord/#{self.name}/' + method.to_s)
98
52
  end
99
-
100
53
  end
101
54
 
102
- # Catch the two entry points into DM::Repository::Adapter that bypass CRUD
103
- # (for when SQL is run directly).
104
- ::DataMapper::Adapters::DataObjectsAdapter.class_eval do
105
-
55
+ DataMapper::Adapters::DataObjectsAdapter.class_eval do
106
56
  add_method_tracer :select, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/select'
107
57
  add_method_tracer :execute, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/execute'
58
+ end
108
59
 
109
- end if defined? ::DataMapper::Adapters::DataObjectsAdapter
110
-
111
- # DM::Validations overrides Model#create, but currently in a way that makes it
112
- # impossible to instrument from one place. I've got a patch pending inclusion
113
- # to make it instrumentable by putting the create method inside ClassMethods.
114
- # This will pick it up if/when that patch is accepted.
115
- ::DataMapper::Validations::ClassMethods.class_eval do
116
-
60
+ DataMapper::Validations::ClassMethods.class_eval do
117
61
  next unless method_defined? :create
118
62
  add_method_tracer :create, 'ActiveRecord/#{self.name}/create'
63
+ end
64
+ end
119
65
 
120
- end if defined? ::DataMapper::Validations::ClassMethods
121
-
122
- # NOTE: DM::Transaction basically calls commit() twice, so as-is it will show
123
- # up in traces twice -- second time subordinate to the first's scope. Works
124
- # well enough.
125
- ::DataMapper::Transaction.module_eval do
126
- add_method_tracer :commit, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/commit'
127
- end if defined? ::DataMapper::Transaction
128
-
129
- module NewRelic
130
- module Agent
131
- module Instrumentation
132
- module DataMapperInstrumentation
133
-
134
- def self.included(klass)
135
- klass.class_eval do
136
- alias_method :log_without_newrelic_instrumentation, :log
137
- alias_method :log, :log_with_newrelic_instrumentation
138
- end
139
- end
66
+ module NewRelic
67
+ module Agent
68
+ module Instrumentation
69
+ module DataMapperInstrumentation
140
70
 
141
- # Unlike in AR, log is called in DM after the query actually ran,
142
- # complete with metrics. Since DO has already calculated the
143
- # duration, there's nothing more to measure, so just record and log.
144
- #
145
- # We rely on the assumption that all possible entry points have been
146
- # hooked with tracers, ensuring that notice_sql attaches this SQL to
147
- # the proper call scope.
148
- def log_with_newrelic_instrumentation(msg)
149
- return unless NewRelic::Agent.is_execution_traced?
150
- return unless operation = case msg.query
151
- when /^\s*select/i then 'find'
152
- when /^\s*(update|insert)/i then 'save'
153
- when /^\s*delete/i then 'destroy'
154
- else nil
155
- end
156
-
157
- # FYI: self.to_s will yield connection URI string.
158
- duration = msg.duration / 1000000.0
159
-
160
- # Attach SQL to current segment/scope.
161
- NewRelic::Agent.instance.transaction_sampler.notice_sql(msg.query, nil, duration)
162
-
163
- # Record query duration associated with each of the desired metrics.
164
- metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
165
- metrics.each do |metric|
166
- NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
167
- end
168
- ensure
169
- log_without_newrelic_instrumentation(msg)
71
+ def self.included(klass)
72
+ klass.class_eval do
73
+ alias_method :log_without_newrelic_instrumentation, :log
74
+ alias_method :log, :log_with_newrelic_instrumentation
170
75
  end
171
-
172
- end # DataMapperInstrumentation
173
- end # Instrumentation
174
- end # Agent
175
- end # NewRelic
176
-
177
- ::DataObjects::Connection.class_eval do
178
- include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
179
- end if defined? ::DataObjects::Connection
180
-
181
- end # if defined? DataMapper
76
+ end
77
+
78
+ # Unlike in AR, log is called in DM after the query actually ran,
79
+ # complete with metrics. Since DO has already calculated the
80
+ # duration, there's nothing more to measure, so just record and log.
81
+ #
82
+ # We rely on the assumption that all possible entry points have been
83
+ # hooked with tracers, ensuring that notice_sql attaches this SQL to
84
+ # the proper call scope.
85
+ def log_with_newrelic_instrumentation(msg)
86
+ return unless NewRelic::Agent.is_execution_traced?
87
+ return unless operation = case msg.query
88
+ when /^\s*select/i then 'find'
89
+ when /^\s*(update|insert)/i then 'save'
90
+ when /^\s*delete/i then 'destroy'
91
+ else nil
92
+ end
93
+
94
+ # FYI: self.to_s will yield connection URI string.
95
+ duration = msg.duration / 1000000.0
96
+
97
+ # Attach SQL to current segment/scope.
98
+ NewRelic::Agent.instance.transaction_sampler.notice_sql(msg.query, nil, duration)
99
+
100
+ # Record query duration associated with each of the desired metrics.
101
+ metrics = [ "ActiveRecord/#{operation}", 'ActiveRecord/all' ]
102
+ metrics.each do |metric|
103
+ NewRelic::Agent.instance.stats_engine.get_stats_no_scope(metric).trace_call(duration)
104
+ end
105
+ ensure
106
+ log_without_newrelic_instrumentation(msg)
107
+ end
108
+
109
+ end # DataMapperInstrumentation
110
+ end # Instrumentation
111
+ end # Agent
112
+ end # NewRelic
113
+
114
+ DataObjects::Connection.class_eval do
115
+ include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
116
+ end
@@ -4,7 +4,7 @@ module NewRelic
4
4
  MAJOR = 3
5
5
  MINOR = 2
6
6
  TINY = 0
7
- BUILD = 3 #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
7
+ BUILD = 4 #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolores_rpm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 105
4
+ hash: 103
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
9
  - 0
10
- - 3
11
- version: 3.2.0.3
10
+ - 4
11
+ version: 3.2.0.4
12
12
  platform: ruby
13
13
  authors:
14
14
  - Bill Kayser
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-05-02 00:00:00 Z
22
+ date: 2012-05-04 00:00:00 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: jeweler
@@ -90,6 +90,7 @@ files:
90
90
  - cert/cacert.pem
91
91
  - cert/oldsite.pem
92
92
  - cert/site.pem
93
+ - dolores_rpm-3.2.0.3.gem
93
94
  - dolores_rpm.gemspec
94
95
  - install.rb
95
96
  - lib/conditional_vendored_dependency_detection.rb