remnant 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,6 +4,19 @@ Remnant hooks into your Rails and discovers your hidden statistics.
4
4
 
5
5
  * Rails 2.3.x
6
6
 
7
+ #### What Remnant Captures
8
+ * request - time it takes for a request to be served
9
+ * action - time it takes for the controller action to finish
10
+ * view - total time for the totality of render to complete
11
+ * templates - time it takes for each template/partial to render
12
+ * filters - time it takes for each filter to run
13
+ * db - total time it takes for all queries to execute
14
+ * queries - time it takes for each sql query to execute
15
+ * gc - time spent inside the GC (if avaialble ree, 1.9.3, etc)
16
+
17
+ These stats are sent to statsd:
18
+ request, action, view, gc, db, filters
19
+
7
20
 
8
21
  #### Install
9
22
 
@@ -36,12 +49,73 @@ Remnant.configure do
36
49
  # environment of application, defaults to Rails.env
37
50
  # included in payload
38
51
  environment "production"
52
+
53
+ hook do |results|
54
+ # custom hook to run after each remnant capture with results
55
+ # results = {key => ms, key2 => ms2}
56
+ end
39
57
  end
40
58
 
41
59
  Remnant::Rails.setup! # needed if on Rails 2.3.x
42
60
  ```
43
61
 
62
+ If you want to capture the times it takes to render templates/partials you
63
+ should enable Template capturing in a before filter (or before rendering
64
+ takes place)
65
+ ```ruby
66
+ before_filter {|c| Remnant::Template.enable! }
67
+ ```
68
+
69
+ If you want to capture the sql query times you should enable Database
70
+ capturing in a before filter (or before rendering takes place)
71
+ ```ruby
72
+ before_filter {|c| Remnant::Database.enable! }
73
+ ```
74
+
44
75
 
76
+ #### Example of using hook
77
+ Below is a way to use all captured information remnant offers
78
+ ```ruby
79
+ hook do |results|
80
+ results.map do |key, ms|
81
+ # loop through specially captures results
82
+ # [request, action, view]
83
+ end
84
+
85
+ # total time for db
86
+ Remnant::Database.total_time.to_i
87
+
88
+ # total time for all filters
89
+ Remnant::Filters.total_time.to_i
90
+
91
+ # time for individual filters
92
+ # [{:type => 'before|after|round',
93
+ # :name => filter_name,
94
+ # :time => microseconds,
95
+ # :ms => ms
96
+ # }]
97
+ Remnant::Filters.filters.to_json
98
+
99
+ # time for individual templates/partials
100
+ # [view => {'time' => ms,
101
+ # 'exclusive' => ms,
102
+ # 'depth' => depth,
103
+ # 'children' => []
104
+ # }]
105
+ if Remnant::Template.enabled?
106
+ Remnant::Template.trace.root.children.map(&:results).to_json
107
+ end
108
+
109
+ # time for sql queries
110
+ if Remnant::Database.enabled?
111
+ queries = Remnant::Database.queries.map {|q| {:sql => q.sql, :ms => q.time * 1000}}
112
+ end
113
+
114
+ # time spent in GC and number of collection attempts
115
+ Remnant::GC.time.to_i
116
+ Remnant::GC.collections.to_i
117
+ end
118
+ ```
45
119
  ###### Note
46
120
  Remnant logs to statsd only if your environment is production, demo or staging.
47
121
  For all other environments it logs via Rails.logger.info
data/lib/remnant/base.rb CHANGED
@@ -43,6 +43,7 @@ class Remnant
43
43
 
44
44
  Remnant.handler.timing("#{key_prefix}.gc", Remnant::GC.time.to_i)
45
45
  Remnant.handler.timing("#{key_prefix}.db", Remnant::Database.total_time.to_i)
46
+ Remnant.handler.timing("#{key_prefix}.filters", Remnant::Filters.total_time.to_i)
46
47
 
47
48
  @sample_counter = 0
48
49
  else
@@ -1,3 +1,3 @@
1
1
  class Remnant
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remnant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: statsd-ruby