scout_rails 1.0.3 → 1.0.4.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.0.4
2
+
3
+ * Added Mongo + Moped instrumentation. Mongo is used for Mongoid < 3.
4
+
1
5
  # 1.0.3
2
6
 
3
7
  * MetricMeta equality - downcase
@@ -291,6 +291,8 @@ module ScoutRails
291
291
  end
292
292
  require File.expand_path(File.join(File.dirname(__FILE__),'instruments/active_record_instruments.rb'))
293
293
  require File.expand_path(File.join(File.dirname(__FILE__),'instruments/net_http.rb'))
294
+ require File.expand_path(File.join(File.dirname(__FILE__),'instruments/moped_instruments.rb'))
295
+ require File.expand_path(File.join(File.dirname(__FILE__),'instruments/mongoid_instruments.rb'))
294
296
  rescue
295
297
  logger.warn "Exception loading instruments:"
296
298
  logger.warn $!.message
@@ -0,0 +1,10 @@
1
+ # Mongoid versions that use Moped should instrument Moped.
2
+ if defined?(::Mongoid) and !defined?(::Moped)
3
+ ScoutRails::Agent.instance.logger.debug "Instrumenting Mongoid"
4
+ Mongoid::Collection.class_eval do
5
+ include ScoutRails::Tracer
6
+ (Mongoid::Collections::Operations::ALL - [:<<, :[]]).each do |method|
7
+ instrument_method method, :metric_name => "MongoDB/\#{@klass}/#{method}"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ if defined?(::Moped)
2
+ ScoutRails::Agent.instance.logger.debug "Instrumenting Moped"
3
+ Moped::Node.class_eval do
4
+ include ScoutRails::Tracer
5
+ def process_with_scout_instruments(operation, &callback)
6
+ if operation.respond_to?(:collection)
7
+ collection = operation.collection
8
+ self.class.instrument("MongoDB/Process/#{collection}/#{operation.class.to_s.split('::').last}", :desc => scout_sanitize_log(operation.log_inspect)) do
9
+ process_without_scout_instruments(operation, &callback)
10
+ end
11
+ end
12
+ end
13
+ alias_method :process_without_scout_instruments, :process
14
+ alias_method :process, :process_with_scout_instruments
15
+
16
+ # replaces values w/ ?
17
+ def scout_sanitize_log(log)
18
+ return nil if log.length > 1000 # safeguard - don't sanitize large SQL statements
19
+ log.gsub(/(=>")((?:[^"]|"")*)"/) do
20
+ $1 + '?' + '"'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module ScoutRails
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4.pre"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
5
- prerelease:
4
+ version: 1.0.4.pre
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derek Haynes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-03 00:00:00.000000000 Z
13
+ date: 2012-08-30 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Monitors a Ruby on Rails application and reports detailed metrics on
16
16
  performance to Scout, a hosted monitoring service.
@@ -31,6 +31,8 @@ files:
31
31
  - lib/scout_rails/config.rb
32
32
  - lib/scout_rails/environment.rb
33
33
  - lib/scout_rails/instruments/active_record_instruments.rb
34
+ - lib/scout_rails/instruments/mongoid_instruments.rb
35
+ - lib/scout_rails/instruments/moped_instruments.rb
34
36
  - lib/scout_rails/instruments/net_http.rb
35
37
  - lib/scout_rails/instruments/process/process_cpu.rb
36
38
  - lib/scout_rails/instruments/process/process_memory.rb
@@ -62,9 +64,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
64
  required_rubygems_version: !ruby/object:Gem::Requirement
63
65
  none: false
64
66
  requirements:
65
- - - ! '>='
67
+ - - ! '>'
66
68
  - !ruby/object:Gem::Version
67
- version: '0'
69
+ version: 1.3.1
68
70
  requirements: []
69
71
  rubyforge_project: scout_rails
70
72
  rubygems_version: 1.8.10