mongo-rails-instrumentation 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,9 +9,9 @@ module Mongo::Rails::Instrumentation
9
9
  attr_internal :mongo_runtime
10
10
 
11
11
  def cleanup_view_runtime
12
- mongo_rt_before_render = LogSubscriber.reset_runtime
12
+ mongo_rt_before_render = LogSubscriber.reset
13
13
  runtime = super
14
- mongo_rt_after_render = LogSubscriber.reset_runtime
14
+ mongo_rt_after_render = LogSubscriber.reset
15
15
  self.mongo_runtime = mongo_rt_before_render + mongo_rt_after_render
16
16
  runtime - mongo_rt_after_render
17
17
  end
@@ -1,20 +1,33 @@
1
1
  require 'mongo/rails/instrumentation'
2
2
 
3
3
  class Mongo::Rails::Instrumentation::LogSubscriber < ActiveSupport::LogSubscriber
4
+ PREFIX = self.class.name.freeze
5
+ COUNT_KEY = PREFIX + "#count".freeze
6
+ RUNTIME_KEY = PREFIX + "#runtime".freeze
7
+
4
8
  def self.runtime=(value)
5
- Thread.current["mongo_mongo_runtime"] = value
9
+ Thread.current[RUNTIME_KEY] = value
6
10
  end
7
11
 
8
12
  def self.runtime
9
- Thread.current["mongo_mongo_runtime"] ||= 0
13
+ Thread.current[RUNTIME_KEY] ||= 0
14
+ end
15
+
16
+ def self.count=(value)
17
+ Thread.current[COUNT_KEY] = value
18
+ end
19
+
20
+ def self.count
21
+ Thread.current[COUNT_KEY] ||= 0
10
22
  end
11
23
 
12
- def self.reset_runtime
13
- rt, self.runtime = runtime, 0
24
+ def self.reset
25
+ rt, self.runtime, self.count = runtime, 0, 0
14
26
  rt
15
27
  end
16
28
 
17
29
  def mongo(event)
18
30
  self.class.runtime += event.duration
31
+ self.class.count += 1
19
32
  end
20
33
  end
@@ -1,7 +1,7 @@
1
1
  module Mongo
2
2
  module Rails
3
3
  module Instrumentation
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Tom Ward"]
10
10
  s.email = ["tom@popdog.net"]
11
11
  s.homepage = "http://tomafro.net"
12
- s.summary = %q{Records time spent in mongo and adds to request logs}
13
- s.description = %q{Records time spent in mongo and adds to request logs}
12
+ s.summary = %q{Record time spent in Mongo and add to request logs}
13
+ s.description = %q{Record time spent in Mongo and add to request logs}
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo-rails-instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Ward
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-19 00:00:00 +00:00
18
+ date: 2011-02-21 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: 3.0.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
- description: Records time spent in mongo and adds to request logs
37
+ description: Record time spent in Mongo and add to request logs
38
38
  email:
39
39
  - tom@popdog.net
40
40
  executables: []
@@ -88,6 +88,6 @@ rubyforge_project:
88
88
  rubygems_version: 1.5.2
89
89
  signing_key:
90
90
  specification_version: 3
91
- summary: Records time spent in mongo and adds to request logs
91
+ summary: Record time spent in Mongo and add to request logs
92
92
  test_files: []
93
93