system-metrics 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.
Files changed (39) hide show
  1. data/README.rdoc +16 -1
  2. data/app/views/layouts/system_metrics/metrics.html.erb +4 -15
  3. data/app/views/system_metrics/metrics/_menu.html.erb +1 -1
  4. data/app/views/system_metrics/metrics/admin.html.erb +1 -1
  5. data/lib/system_metrics/engine.rb +3 -3
  6. data/lib/system_metrics/instrument/base.rb +1 -1
  7. data/lib/system_metrics/nested_event.rb +8 -1
  8. data/lib/system_metrics/store.rb +10 -15
  9. data/lib/system_metrics/version.rb +1 -1
  10. data/public/images/gradient.png +0 -0
  11. data/public/stylesheets/app.css +197 -3
  12. data/spec/spec_helper.rb +2 -0
  13. data/spec/support/db_setup.rb +3 -0
  14. data/spec/support/mock_app.rb +1 -3
  15. data/spec/support/notifications_support.rb +10 -0
  16. data/spec/system_metrics/collector_spec.rb +1 -2
  17. data/spec/system_metrics/config_spec.rb +16 -8
  18. data/spec/system_metrics/engine_spec.rb +53 -28
  19. data/spec/system_metrics/instrument/action_controller_spec.rb +51 -0
  20. data/spec/system_metrics/instrument/action_mailer_spec.rb +40 -0
  21. data/spec/system_metrics/instrument/action_view_spec.rb +40 -0
  22. data/spec/system_metrics/instrument/active_record_spec.rb +50 -0
  23. data/spec/system_metrics/instrument/base_spec.rb +38 -0
  24. data/spec/system_metrics/instrument/rack_spec.rb +28 -0
  25. data/spec/system_metrics/middleware_spec.rb +1 -3
  26. data/spec/system_metrics/nested_event_spec.rb +87 -0
  27. data/spec/system_metrics/store_spec.rb +49 -0
  28. data/spec/system_metrics_spec.rb +0 -1
  29. data/system-metrics.gemspec +1 -0
  30. metadata +30 -11
  31. data/public/stylesheets/base.css +0 -46
  32. data/public/stylesheets/footer.css +0 -6
  33. data/public/stylesheets/graphs.css +0 -9
  34. data/public/stylesheets/header.css +0 -52
  35. data/public/stylesheets/menu_bar.css +0 -7
  36. data/public/stylesheets/metric.css +0 -19
  37. data/public/stylesheets/payload.css +0 -4
  38. data/public/stylesheets/portlet.css +0 -11
  39. data/public/stylesheets/title_bar.css +0 -29
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'system_metrics/metric'
3
+
4
+ describe SystemMetrics::Store do
5
+ include NotificationsSupport
6
+
7
+ describe '#save' do
8
+ it 'should save an array of events hierarchically' do
9
+ parent = event(:start => Time.now - 10.seconds, :end => Time.now)
10
+ child = event(:start => Time.now - 9.seconds, :end => Time.now - 1.seconds)
11
+ grandchild = event(:start => Time.now - 8.seconds, :end => Time.now - 2.seconds)
12
+
13
+ store = SystemMetrics::Store.new
14
+
15
+ lambda {
16
+ store.save([grandchild, child, parent])
17
+ }.should change(SystemMetrics::Metric, :count).by(3)
18
+
19
+ metrics = SystemMetrics::Metric.all
20
+ verify_equal(parent, metrics[0])
21
+ verify_equal(child, metrics[0].children[0])
22
+ verify_equal(grandchild, metrics[0].children[0].children[0])
23
+ end
24
+
25
+ it 'should not attempt to save anything if passed an empty array of events' do
26
+ store = SystemMetrics::Store.new
27
+ lambda { store.save([]) }.should_not change(SystemMetrics::Metric, :count)
28
+ end
29
+
30
+ it 'should not attempt to save anything if passed a nil' do
31
+ store = SystemMetrics::Store.new
32
+ lambda { store.save(nil) }.should_not change(SystemMetrics::Metric, :count)
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def verify_equal(event, metric)
39
+ event.name.should == metric.name
40
+ event.action.should == metric.action
41
+ event.category.should == metric.category
42
+ event.transaction_id.should == metric.transaction_id
43
+ event.payload.should == metric.payload
44
+ event.started_at.should be_within(1).of(metric.started_at)
45
+ event.duration.should be_within(1).of(metric.duration)
46
+ event.exclusive_duration.should be_within(1).of(metric.exclusive_duration)
47
+ end
48
+
49
+ end
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
- require 'system_metrics'
3
2
 
4
3
  describe SystemMetrics do
5
4
  it 'should allow setting collection status to off' do
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_development_dependency('rspec', '2.5.0')
23
23
  s.add_development_dependency('sqlite3-ruby', '1.3.3')
24
+ s.add_development_dependency('rdoc', '3.8')
24
25
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: system-metrics
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Kunkle
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-19 00:00:00 -04:00
13
+ date: 2011-08-11 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -46,6 +46,17 @@ dependencies:
46
46
  version: 1.3.3
47
47
  type: :development
48
48
  version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rdoc
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - "="
56
+ - !ruby/object:Gem::Version
57
+ version: "3.8"
58
+ type: :development
59
+ version_requirements: *id004
49
60
  description: System Metrics is a Rails 3 Engine that provides a clean web interface to the performance metrics instrumented with ActiveSupport::Notifications
50
61
  email:
51
62
  executables: []
@@ -92,20 +103,12 @@ files:
92
103
  - lib/system_metrics/nested_event.rb
93
104
  - lib/system_metrics/store.rb
94
105
  - lib/system_metrics/version.rb
106
+ - public/images/gradient.png
95
107
  - public/images/rings_13.png
96
108
  - public/stylesheets/app.css
97
- - public/stylesheets/base.css
98
- - public/stylesheets/footer.css
99
- - public/stylesheets/graphs.css
100
- - public/stylesheets/header.css
101
109
  - public/stylesheets/ie.css
102
- - public/stylesheets/menu_bar.css
103
- - public/stylesheets/metric.css
104
- - public/stylesheets/payload.css
105
- - public/stylesheets/portlet.css
106
110
  - public/stylesheets/print.css
107
111
  - public/stylesheets/reset.css
108
- - public/stylesheets/title_bar.css
109
112
  - public/stylesheets/typography.css
110
113
  - spec/spec_helper.rb
111
114
  - spec/support/db_setup.rb
@@ -117,7 +120,15 @@ files:
117
120
  - spec/system_metrics/collector_spec.rb
118
121
  - spec/system_metrics/config_spec.rb
119
122
  - spec/system_metrics/engine_spec.rb
123
+ - spec/system_metrics/instrument/action_controller_spec.rb
124
+ - spec/system_metrics/instrument/action_mailer_spec.rb
125
+ - spec/system_metrics/instrument/action_view_spec.rb
126
+ - spec/system_metrics/instrument/active_record_spec.rb
127
+ - spec/system_metrics/instrument/base_spec.rb
128
+ - spec/system_metrics/instrument/rack_spec.rb
120
129
  - spec/system_metrics/middleware_spec.rb
130
+ - spec/system_metrics/nested_event_spec.rb
131
+ - spec/system_metrics/store_spec.rb
121
132
  - spec/system_metrics_spec.rb
122
133
  - system-metrics.gemspec
123
134
  has_rdoc: true
@@ -159,5 +170,13 @@ test_files:
159
170
  - spec/system_metrics/collector_spec.rb
160
171
  - spec/system_metrics/config_spec.rb
161
172
  - spec/system_metrics/engine_spec.rb
173
+ - spec/system_metrics/instrument/action_controller_spec.rb
174
+ - spec/system_metrics/instrument/action_mailer_spec.rb
175
+ - spec/system_metrics/instrument/action_view_spec.rb
176
+ - spec/system_metrics/instrument/active_record_spec.rb
177
+ - spec/system_metrics/instrument/base_spec.rb
178
+ - spec/system_metrics/instrument/rack_spec.rb
162
179
  - spec/system_metrics/middleware_spec.rb
180
+ - spec/system_metrics/nested_event_spec.rb
181
+ - spec/system_metrics/store_spec.rb
163
182
  - spec/system_metrics_spec.rb
@@ -1,46 +0,0 @@
1
- body {
2
- font-size: 72%;
3
- line-height: 150%;
4
- color: #323537;
5
- background: #EFEFEF;
6
- }
7
-
8
- h1, h2, h3, h4, h5, h6 {
9
- color: #F47721;
10
- font-weight: normal;
11
- }
12
-
13
- tbody tr:nth-child(2n) td, tbody tr.even td {
14
- background-color: #EFEFEF;
15
- }
16
-
17
- thead th {
18
- background-color: #6A7176;
19
- color: #CDCDCD;
20
- }
21
-
22
- a {
23
- color: #323537;
24
- text-decoration: none;
25
- }
26
-
27
- a:hover {
28
- color: #F47721;
29
- text-decoration: underline;
30
- }
31
-
32
- input[type=submit] {
33
- background: #EFEFEF;
34
- padding: 6px 10px 4px;
35
- border: none;
36
- -moz-border-radius: 10px;
37
- -webkit-border-radius: 10px;
38
- border-radius: 10px;
39
- }
40
-
41
- input[type=submit]:hover {
42
- background: #7B8389;
43
- color: #FFF;
44
- cursor: pointer;
45
- }
46
-
@@ -1,6 +0,0 @@
1
- #footer {
2
- text-align: center;
3
- border-top: 1px solid #CCC;
4
- font-size: 85%;
5
- min-height: 2em;
6
- }
@@ -1,9 +0,0 @@
1
- .hbar {
2
- display: block;
3
- background: #0A0;
4
- height: 10px;
5
- }
6
-
7
- .hbar.slow {
8
- background: #A00;
9
- }
@@ -1,52 +0,0 @@
1
- #header {
2
- color: white;
3
- background-color: #6A7176;
4
- border-bottom: 1px solid #44484B;
5
- padding: 9px 30px;
6
- position: relative;
7
- text-shadow: 0 1px 0 black;
8
- z-index: 900;
9
- }
10
-
11
- #header h1 {
12
- color: #CDCDCD;
13
- display: inline;
14
- font-size: 1.3em;
15
- margin-right: 20px;
16
- }
17
-
18
- #header a, #header a:link {
19
- color: #CDCDCD;
20
- }
21
-
22
- #header ul#tabs {
23
- display: inline;
24
- height: 100%;
25
- }
26
-
27
- #header ul#tabs li {
28
- display: inline;
29
- font-size: 1em;
30
- margin-right: 4px;
31
- padding: 9px 0;
32
- position: relative;
33
- }
34
-
35
- #header ul#tabs li a {
36
- padding: 6px 10px 4px;
37
- position: relative;
38
- text-decoration: none;
39
- -moz-border-radius: 10px;
40
- -webkit-border-radius: 10px;
41
- border-radius: 10px;
42
- }
43
-
44
- #header ul#tabs li:hover > a {
45
- background: #7B8389;
46
- color: #FFF;
47
- }
48
-
49
- #header img {
50
- position: relative;
51
- top: 2px;
52
- }
@@ -1,7 +0,0 @@
1
- #menu-bar {
2
- margin-bottom: 10px;
3
- }
4
-
5
- #menu-bar form {
6
- float: right;
7
- }
@@ -1,19 +0,0 @@
1
- #metric-details {
2
- border-right: 1px solid #EFEFEF;
3
- float: left;
4
- padding-right: 20px;
5
- width: 37%;
6
- }
7
-
8
- #metric-details h2 {
9
- font-size: 500%;
10
- line-height: normal;
11
- margin-bottom: 20px;
12
- color: #323537;
13
- text-align: center;
14
- }
15
-
16
- #metric-children {
17
- float: right;
18
- width: 60%;
19
- }
@@ -1,4 +0,0 @@
1
- div.payload {
2
- border-left: 1px solid #EFEFEF;
3
- padding-left: 10px;
4
- }
@@ -1,11 +0,0 @@
1
- div.portlet {
2
- position: relative;
3
- float: left;
4
- width: 45em;
5
- border: 1px solid #EDEDED;
6
- padding: 10px;
7
- margin: 0 10px 10px 0;
8
- -moz-box-shadow: 1px 1px 1px #AAA;
9
- -webkit-box-shadow: 1px 1px 1px #AAA;
10
- box-shadow: 1px 1px 1px #AAA;
11
- }
@@ -1,29 +0,0 @@
1
- #title-bar {
2
- background: #EFEFEF;
3
- border-bottom: 1px solid #EDEDED;
4
- color: #5E6469;
5
- font-size: 1em;
6
- font-weight: bold;
7
- line-height: 140%;
8
- padding: 10px 30px;
9
- position: relative;
10
- text-shadow: 0 1px 0 white;
11
- -moz-box-shadow: 0 1px 2px #AAAAAA;
12
- -webkit-box-shadow: 0 1px 2px #AAAAAA;
13
- box-shadow: 0 1px 2px #AAAAAA;
14
- }
15
-
16
- #title-bar h2 {
17
- font-size: 2.6em;
18
- font-weight: bold;
19
- margin: 12px 0 10px;
20
- }
21
-
22
- #title-bar h4 {
23
- margin-bottom: 0.25em;
24
- color: #5E6469;
25
- }
26
-
27
- #title-bar h4 a {
28
- color: #5E6469;
29
- }