owl_tracer 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c64ba3066ebfd34cc6fcd4127138d05a1085c61e
4
- data.tar.gz: 3d244f622b1193cb39fc9be7428091394ba901cc
3
+ metadata.gz: c42d80ec7ba1b782db71b248e0460da164ea9ffd
4
+ data.tar.gz: 2010716dc039b6260f92cdec18c1426a7604fb32
5
5
  SHA512:
6
- metadata.gz: d57d0b92e9572fd4a0cba956c7303e18d94250e4da12a73a0a83d7085f250b786747e9e5c546fe21686d7f7615929d81948c7b3aa749716f72ca1f24fa8b56ce
7
- data.tar.gz: 719ecd38bd50bc4a48076095350f44fda7d459e5b0f1ded57c44a9456c6151d50616e20e0534b425731f1cad8bb469ba0211f22e4a2881f40f38ab79d92a04f5
6
+ metadata.gz: 4b5043665a19c4a96a372fe62c1324e99c28f382a7b60e4667631cb79341df41c0e05beaef423ce41631751ea1eb282a8d59d4d777d537192e7fc1ccedba5458
7
+ data.tar.gz: dc8b0af590f0d1aa1317937ae6ff2b530e42e42e38c0439657d0873f31fe31810579c2ac63b82424f01992883f001c4edbb02b92bf9c8cd6844859b696f6c586
data/README.md CHANGED
@@ -39,10 +39,10 @@ StatsCalculator::calc (118 ms)
39
39
  ```
40
40
 
41
41
  You can also skip the number of milliseconds or pass 0 and this will produce a very verbose list of all method calls that happened between the tracer was instantiated until you asked for the dump.
42
- The first time you call `dump_results`, it stops recording new calls, but you can call `dump_results` multiple times with a different number to zoom in or out what was recorded.
42
+ The first time you call `dump_results`, it stops recording new calls, but you can call `dump_results` multiple times with different numbers to zoom in or out what was recorded.
43
43
 
44
44
  ## Web Usage
45
- To figure out why some route is slow in your application, just add this to your app's `application_controller`:
45
+ To figure out why a route is slow in your web app, just add this to your app's `application_controller`:
46
46
 
47
47
  ```
48
48
  class ApplicationController < ActionController::Base
@@ -74,7 +74,7 @@ class ApplicationController < ActionController::Base
74
74
  end
75
75
  ```
76
76
 
77
- after that, you can just do `http://your_server/whatever_endpoint_you_want?owl_tracer=200` to get everything that is taking more than `200ms` , including both controller time, rendering time and code triggered by the view time, like:
77
+ after that, you can add `?owl_tracer=200` (or `&owl_tracer=200`) to any route, like for example `http://your_server/whatever_endpoint_you_want?owl_tracer=200` to get everything that is taking more than `200ms` , including controller time, rendering time and code triggered by the view time, like:
78
78
 
79
79
  ```
80
80
  SlowController::show (1073 ms)
@@ -99,7 +99,5 @@ show.html.slim::rendering (2474 ms)
99
99
  _bank_info.html.slim::rendering (217 ms)
100
100
  ```
101
101
 
102
- ### and now you know why that routs is slow! :-)
103
-
104
-
102
+ making it easier to identify why the route is slow.
105
103
 
data/lib/owl_tracer.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  class OwlTracer
2
- def initialize
2
+ def initialize(timeout = 30)
3
+ @stop_at = Time.now.to_f + timeout if timeout
4
+
3
5
  start
4
6
  end
5
7
 
@@ -32,7 +34,6 @@ class OwlTracer
32
34
  @spent = []
33
35
  @level = 0
34
36
  @trace = TracePoint.new(:call, :return, :b_return) do |tp|
35
-
36
37
  calls_to_ignore = ["/lib/ruby/", "/gems/", "(eval)"]
37
38
  if calls_to_ignore.none? { |substr| tp.path.include?(substr) } # app's method calls only
38
39
  if tp.event == :call
@@ -48,6 +49,9 @@ class OwlTracer
48
49
  end
49
50
  end
50
51
  end
52
+ if @stop_at && Time.now.to_f > @stop_at
53
+ @trace.disable
54
+ end
51
55
  end
52
56
  @trace.enable
53
57
  end
data/owl_tracer.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "owl_tracer"
3
- s.version = "0.0.3"
4
- s.date = "2016-11-05"
3
+ s.version = "0.0.4"
4
+ s.date = "2016-11-07"
5
5
  s.summary = "Easy to use performance tracer for Ruby"
6
6
  s.description = "Easy to use performance tracer for Ruby"
7
7
  s.authors = ["Gui Carvalho"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owl_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gui Carvalho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy to use performance tracer for Ruby
14
14
  email: guilherme@konkix.com