stack_tracy 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = StackTracy CHANGELOG
2
2
 
3
+ == Version 0.1.7 (August 30, 2012)
4
+
5
+ * Added 'realtime' cumulatives tab within the stack tree HTML page ^^
6
+
3
7
  == Version 0.1.6 (August 28, 2012)
4
8
 
5
9
  * Always logging trace messages (despite of the :only and/or :exclude options)
data/README.md CHANGED
@@ -384,7 +384,7 @@ Also, you can determine what StackTracy has to do after the request has finished
384
384
 
385
385
  This will immediately open the stack tree in your default browser after every traced request:
386
386
 
387
- use StackTracy::Sinatra, :open do
387
+ use StackTracy::Sinatra, :open do |path, params|
388
388
  path == "/paul/engel" #=> only trace and open stack tree when opening "http://localhost:4567/paul/engel"
389
389
  end
390
390
 
@@ -399,7 +399,7 @@ The StackTracy repo is provided with `script/console` which you can use for deve
399
399
  Run the following command in your console:
400
400
 
401
401
  $ script/console
402
- Loading development environment (StackTracy 0.1.6)
402
+ Loading development environment (StackTracy 0.1.7)
403
403
  [1] pry(main)> stack_tracy :print do
404
404
  [1] pry(main)* puts "testing"
405
405
  [1] pry(main)* end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -1,7 +1,7 @@
1
1
  module StackTracy #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 6
4
+ TINY = 7
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
data/stack_tracy.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "stack_tracy"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = "0.1.6"
16
+ gem.version = "0.1.7"
17
17
 
18
18
  gem.add_dependency "rich_support", "~> 0.1.2"
19
19
  gem.add_dependency "launchy", "2.1.0"
@@ -88,7 +88,8 @@ a {
88
88
  *display: inline;
89
89
  zoom: 1; }
90
90
 
91
- #page #cumulatives div span.count {
91
+ #page #cumulatives div span.count,
92
+ #page #realtime_cumulatives div span.count {
92
93
  width: 45px; }
93
94
 
94
95
  #footer {
@@ -1,7 +1,7 @@
1
1
  if (typeof(StackTracy) == "undefined") {
2
2
 
3
3
  StackTracy = (function() {
4
- var sortation = [];
4
+ var sortation = {cumulatives: [], realtime_cumulatives: []};
5
5
 
6
6
  var toggle = function(event) {
7
7
  var group = $(event.target).closest("div").next("div.group");
@@ -22,12 +22,12 @@ StackTracy = (function() {
22
22
  });
23
23
 
24
24
  return {
25
- version: "0.1.6",
26
- sort: function(column) {
27
- sortation[column] = sortation[column] == "asc" ? "desc" : "asc";
28
- $("#cumulatives>.body>div").tsort("span:eq(" + column + ")[abbr]", {
25
+ version: "0.1.7",
26
+ sort: function(section, column) {
27
+ sortation[section][column] = sortation[section][column] == "asc" ? "desc" : "asc";
28
+ $("#" + section + ">.body>div").tsort("span:eq(" + column + ")[abbr]", {
29
29
  sortFunction: function(a, b) {
30
- var order = (sortation[column] == "asc") ? 1 : -1;
30
+ var order = (sortation[section][column] == "asc") ? 1 : -1;
31
31
  var av = column == 3 ? a.s : parseFloat(a.s);
32
32
  var bv = column == 3 ? b.s : parseFloat(b.s);
33
33
  if (av === bv) {
data/ui/index.html.erb CHANGED
@@ -26,6 +26,9 @@
26
26
  <li>
27
27
  <a href="#cumulatives" data-toggle="tab">Cumulatives</a>
28
28
  </li>
29
+ <li>
30
+ <a href="#realtime_cumulatives" data-toggle="tab">Realtime cumulatives</a>
31
+ </li>
29
32
  </ul>
30
33
  <div class="tab-content"><%
31
34
  limited = events.size > limit
@@ -39,6 +42,7 @@
39
42
  last_depth = nil
40
43
  last_duration = nil
41
44
  corrections = []
45
+ stack = []
42
46
  cumulatives = {} %>
43
47
  <div class="tab-pane active" id="stack_trace">
44
48
  <div class="head">
@@ -55,13 +59,23 @@
55
59
  if skip
56
60
  corrections.unshift event[:depth] if corrections.empty? || corrections.first != event[:depth]
57
61
  else
58
- cumulatives[event[:call]] ||= {:duration => 0.0, :count => 0}
59
- cumulatives[event[:call]][:duration] += event[:duration].to_f
60
- cumulatives[event[:call]][:count] += 1
61
- cumulatives[event[:call]][:average] = cumulatives[event[:call]][:duration].to_f / cumulatives[event[:call]][:count].to_f
62
+ cumulative = (cumulatives[event[:call]] ||= {:duration => 0.0, :count => 0, :real_duration => 0.0, :real_count => 0})
63
+ cumulative[:duration] += event[:duration].to_f
64
+ cumulative[:count] += 1
65
+ cumulative[:average] = cumulative[:duration].to_f / cumulative[:count].to_f
66
+
62
67
  corrections.size.times do |i|
63
68
  event[:depth] <= corrections[0] ? corrections.shift : break
64
69
  end
70
+
71
+ stack = stack[0, event[:depth] - corrections.size]
72
+ unless stack.include? event[:call]
73
+ cumulative[:real_duration] += event[:duration].to_f
74
+ cumulative[:real_count] += 1
75
+ cumulative[:real_average] = cumulative[:real_duration].to_f / cumulative[:real_count].to_f
76
+ end
77
+ stack << event[:call]
78
+
65
79
  if last_depth.to_i < event[:depth] - corrections.size %>
66
80
  <div class="group"><% if threshold && comment_depth.nil? && last_duration && last_duration < threshold %><% comment_depth = event[:depth] - corrections.size %><%= "\n<!--" %><% end %><% else
67
81
  close_tags = ((event[:depth] - corrections.size + 1)..last_depth.to_i).collect do |depth|
@@ -95,10 +109,10 @@ end.reverse.join("")
95
109
  </div>
96
110
  <div class="tab-pane" id="cumulatives">
97
111
  <div class="head">
98
- <span class="average"><a href="javascript:StackTracy.sort(0)">Average</a></span>
99
- <span class="duration"><a href="javascript:StackTracy.sort(1)">Duration</a></span>
100
- <span class="count"><a href="javascript:StackTracy.sort(2)">Count</a></span>
101
- <span class="call"><a href="javascript:StackTracy.sort(3)">Call</a></span>
112
+ <span class="average"><a href="javascript:StackTracy.sort('cumulatives', 0)">Average</a></span>
113
+ <span class="duration"><a href="javascript:StackTracy.sort('cumulatives', 1)">Duration</a></span>
114
+ <span class="count"><a href="javascript:StackTracy.sort('cumulatives', 2)">Count</a></span>
115
+ <span class="call"><a href="javascript:StackTracy.sort('cumulatives', 3)">Call</a></span>
102
116
  </div>
103
117
  <div class="body"><% cumulatives.sort{|(ak, av), (bk, bv)| bv[:average] <=> av[:average]}.each do |call, stats| %>
104
118
  <div>
@@ -106,6 +120,22 @@ end.reverse.join("")
106
120
  <span class="duration" abbr="<%= "%.6f" % stats[:duration] %>"><%= "%.6f" % stats[:duration] %></span>
107
121
  <span class="count" abbr="<%= stats[:count] %>"><%= stats[:count] %></span>
108
122
  <span class="call" abbr="<%= call.gsub("<", "&lt;").gsub(">", "&gt;") %>"><%= call.gsub("<", "&lt;").gsub(">", "&gt;").gsub(/^"(.*)"$/){ "<strong>#{$1}</strong>" } %></span>
123
+ </div><% end %>
124
+ </div>
125
+ </div>
126
+ <div class="tab-pane" id="realtime_cumulatives">
127
+ <div class="head">
128
+ <span class="average"><a href="javascript:StackTracy.sort('realtime_cumulatives', 0)">Average</a></span>
129
+ <span class="duration"><a href="javascript:StackTracy.sort('realtime_cumulatives', 1)">Duration</a></span>
130
+ <span class="count"><a href="javascript:StackTracy.sort('realtime_cumulatives', 2)">Count</a></span>
131
+ <span class="call"><a href="javascript:StackTracy.sort('realtime_cumulatives', 3)">Call</a></span>
132
+ </div>
133
+ <div class="body"><% cumulatives.sort{|(ak, av), (bk, bv)| bv[:real_average] <=> av[:real_average]}.each do |call, stats| %>
134
+ <div>
135
+ <span class="average" abbr="<%= "%.6f" % stats[:real_average] %>"><%= "%.6f" % stats[:real_average] %></span>
136
+ <span class="duration" abbr="<%= "%.6f" % stats[:real_duration] %>"><%= "%.6f" % stats[:real_duration] %></span>
137
+ <span class="count" abbr="<%= stats[:real_count] %>"><%= stats[:real_count] %></span>
138
+ <span class="call" abbr="<%= call.gsub("<", "&lt;").gsub(">", "&gt;") %>"><%= call.gsub("<", "&lt;").gsub(">", "&gt;").gsub(/^"(.*)"$/){ "<strong>#{$1}</strong>" } %></span>
109
139
  </div><% end %>
110
140
  </div>
111
141
  </div>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stack_tracy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.6
5
+ version: 0.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Engel
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-28 00:00:00 Z
13
+ date: 2012-08-29 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rich_support