mongo-rails-instrumentation 0.1.0 → 0.2.0
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.
@@ -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.
|
12
|
+
mongo_rt_before_render = LogSubscriber.reset
|
13
13
|
runtime = super
|
14
|
-
mongo_rt_after_render = LogSubscriber.
|
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[
|
9
|
+
Thread.current[RUNTIME_KEY] = value
|
6
10
|
end
|
7
11
|
|
8
12
|
def self.runtime
|
9
|
-
Thread.current[
|
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.
|
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
|
@@ -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{
|
13
|
-
s.description = %q{
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 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-
|
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:
|
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:
|
91
|
+
summary: Record time spent in Mongo and add to request logs
|
92
92
|
test_files: []
|
93
93
|
|