owl_tracer 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d0588e86dbb24affa977b1962b80ce59cd0d178
4
- data.tar.gz: 1aaacd500684f8fc7e08f56cf08f1456de59f1f9
3
+ metadata.gz: c64ba3066ebfd34cc6fcd4127138d05a1085c61e
4
+ data.tar.gz: 3d244f622b1193cb39fc9be7428091394ba901cc
5
5
  SHA512:
6
- metadata.gz: c5ee34312717a42036ff72c34eee1e73f2c8b574aa2e1bb66b409f2a1148eadf53ba391bc1f28476056b063e5ef6e3c526783ab99d1cf2ffb8a66fbd71e80363
7
- data.tar.gz: c34d2bd208df8deb1b3c61bd4545829503a19f9414057a1f8cbf7854c3e84214309032b16d5057a9335ff0c061685ac147a498084cfa305dc5fb081fe386dd09
6
+ metadata.gz: d57d0b92e9572fd4a0cba956c7303e18d94250e4da12a73a0a83d7085f250b786747e9e5c546fe21686d7f7615929d81948c7b3aa749716f72ca1f24fa8b56ce
7
+ data.tar.gz: 719ecd38bd50bc4a48076095350f44fda7d459e5b0f1ded57c44a9456c6151d50616e20e0534b425731f1cad8bb469ba0211f22e4a2881f40f38ab79d92a04f5
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ Easy to use performance tracer for Ruby
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'owl_tracer'
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Step 1, instantiate the tracer:
14
+ ```
15
+ tracer = OwlTracer.new
16
+ ```
17
+
18
+ Step 2, run whatever code you want to benchmark. Let's say we run two commands:
19
+ ```
20
+ review_presenter.prepare
21
+ stats_calcularor.calc
22
+ ```
23
+
24
+ Step 3, get the results:
25
+ ```
26
+ pp tracer.dump_results(100) # Only calls that took at least 100ms will be reported
27
+ ```
28
+ and you'll receive an array of strings with all your application method calls with how many milliseconds it took to run, properly idented. It will look like this:
29
+ ```
30
+ ReviewPresenter::prepare (1273 ms)
31
+ ChildPresenter::initialize (1047 ms)
32
+ ChildPresenter::initialize_pricing_instance_variables (260 ms)
33
+ ChildPresenter::initialize_quoted_rate_presenter (203 ms)
34
+ IncomePresenter::initialize_income_presenter (260 ms)
35
+ JobPresenter::initialize (238 ms)
36
+ Review::JobVerifier::initialize (238 ms)
37
+ Review::JobVerifier::load_jobs (130 ms)
38
+ StatsCalculator::calc (118 ms)
39
+ ```
40
+
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.
43
+
44
+ ## Web Usage
45
+ To figure out why some route is slow in your application, just add this to your app's `application_controller`:
46
+
47
+ ```
48
+ class ApplicationController < ActionController::Base
49
+ ...
50
+ around_action :owl_tracer_logger
51
+ ...
52
+
53
+ def global_request_logging
54
+ # if a param comes in the request, we start the tracer
55
+ if params[:owl_tracer]
56
+ tracer = OwlTracer.new
57
+ end
58
+
59
+ # we let the request be hadled normally
60
+ yield
61
+
62
+ if params[:owl_tracer]
63
+ # get the results
64
+ trace_result = tracer.dump_results(params[:owl_tracer].to_i)
65
+
66
+ # them write it to a log file
67
+ File.write("/tmp/owl_tracer.txt", trace_result.join("\n"))
68
+
69
+ # or print it in the logs
70
+ warn(trace_result)
71
+
72
+ # or email it to you... or save it on S3... etc.
73
+ end
74
+ end
75
+ ```
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:
78
+
79
+ ```
80
+ SlowController::show (1073 ms)
81
+ PastPresenter::initialize (1047 ms)
82
+ PastPresenter::initialize_pricing_instance_variables (260 ms)
83
+ PastPresenter::initialize_quoted_rate_PastPresenter (203 ms)
84
+ PastPresenter::initialize_income_PastPresenter (260 ms)
85
+ JobPastPresenter::initialize (238 ms)
86
+ Slow::JobVerifier::initialize (238 ms)
87
+ show.html.slim::rendering (2474 ms)
88
+ _summary.html.slim::rendering (1842 ms)
89
+ _collapse_panels.html.slim::rendering (549 ms)
90
+ _Education_panel.html.slim::rendering (389 ms)
91
+ EducationPresenter::data_json (386 ms)
92
+ EducationPresenter::data_hash (345 ms)
93
+ EducationPresenter::verifications (306 ms)
94
+ sHelper::_supportables (225 ms)
95
+ #<Class:SupportingDocs::SupportableServicer>::get_all_doc_supportables (225 ms)
96
+ _tabs.html.slim::rendering (558 ms)
97
+ _info_tab.html.slim::rendering (427 ms)
98
+ _education_info.html.slim::rendering (261 ms)
99
+ _bank_info.html.slim::rendering (217 ms)
100
+ ```
101
+
102
+ ### and now you know why that routs is slow! :-)
103
+
104
+
105
+
data/owl_tracer.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "owl_tracer"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.date = "2016-11-05"
5
5
  s.summary = "Easy to use performance tracer for Ruby"
6
- s.description = "Logs how much time each method call is taking and returns an idented list"
6
+ s.description = "Easy to use performance tracer for Ruby"
7
7
  s.authors = ["Gui Carvalho"]
8
8
  s.email = "guilherme@konkix.com"
9
9
  s.files = `git ls-files -z`.split("\x0").reject do |f|
10
10
  f.match(%r{^(test/|\.gitignore|\.travis)})
11
11
  end
12
- s.require_paths = ['lib']
12
+ s.require_paths = ["lib"]
13
13
  s.homepage = "https://github.com/guimonz/owl_tracer"
14
14
  s.license = "MIT"
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owl_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gui Carvalho
@@ -10,8 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Logs how much time each method call is taking and returns an idented
14
- list
13
+ description: Easy to use performance tracer for Ruby
15
14
  email: guilherme@konkix.com
16
15
  executables: []
17
16
  extensions: []
@@ -19,9 +18,8 @@ extra_rdoc_files: []
19
18
  files:
20
19
  - Gemfile
21
20
  - Gemfile.lock
22
- - README
21
+ - README.md
23
22
  - lib/owl_tracer.rb
24
- - owl_tracer-0.0.1.gem
25
23
  - owl_tracer.gemspec
26
24
  homepage: https://github.com/guimonz/owl_tracer
27
25
  licenses:
data/README DELETED
@@ -1,2 +0,0 @@
1
-
2
-
data/owl_tracer-0.0.1.gem DELETED
Binary file