harness-actioncontroller 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +9 -0
- data/harness-acioncontroller.gemspec +25 -0
- data/lib/harness-actioncontroller.rb +1 -0
- data/lib/harness/action_controller.rb +13 -0
- data/lib/harness/actioncontroller/version.rb +5 -0
- data/test/action_controller_test.rb +37 -0
- data/test/test_helper.rb +63 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0949d7b405b85c588b9b2030d55ee95edfce4fe
|
4
|
+
data.tar.gz: fba78a4a754d5046b5bd695a0e0d095f7bf8019d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2aba9c85397477aa2f425c4647f37532e62d3465f29377d65ce1d9eca670ac794cf9a66325d78ece99e7097a02bf5e38b5f886dfb7446b35c20e3dca3244bdaa
|
7
|
+
data.tar.gz: 6cb547987acb21adb8617f35146ba004dffdcaf2fd7ce742de89d79907c63d620811d98416b002608632be218443ef692e06005f5b509bf69219ffdd8cad87f8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 ahawkins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Harness::ActionController
|
2
|
+
|
3
|
+
Log all `ActionController`'s performance metrics to Harness.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'harness-actioncontroller'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install harness-actioncontroller
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
All you need to do is require the file:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'harness-actioncontroller'
|
25
|
+
```
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'harness/actioncontroller/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "harness-actioncontroller"
|
8
|
+
spec.version = Harness::ActionController::VERSION
|
9
|
+
spec.authors = ["ahawkins"]
|
10
|
+
spec.email = ["adam@hawkins.io"]
|
11
|
+
spec.description = %q{Foward ActionController's internal metrics to Harness}
|
12
|
+
spec.summary = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "harness"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'harness/action_controller'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'harness'
|
2
|
+
|
3
|
+
events = %w(write_fragment read_fragment expire_fragment process_action send_file)
|
4
|
+
|
5
|
+
events.each do |name|
|
6
|
+
ActiveSupport::Notifications.subscribe "#{name}.action_controller" do |*args|
|
7
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
8
|
+
|
9
|
+
controller, action = event.payload.fetch(:controller), event.payload.fetch(:action)
|
10
|
+
|
11
|
+
Harness.timing "action_controller.#{name}.#{controller}.#{action}", event.duration
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class ActionControllerIntegration < MiniTest::Unit::TestCase
|
4
|
+
def test_logs_write_fragment
|
5
|
+
instrument "write_fragment"
|
6
|
+
|
7
|
+
assert_timer "action_controller.write_fragment.foo.bar"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_logs_read_fragment
|
11
|
+
instrument "read_fragment"
|
12
|
+
|
13
|
+
assert_timer "action_controller.read_fragment.foo.bar"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_logs_expire_fragment
|
17
|
+
instrument "expire_fragment"
|
18
|
+
|
19
|
+
assert_timer "action_controller.expire_fragment.foo.bar"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_logs_process_action
|
23
|
+
instrument "process_action"
|
24
|
+
|
25
|
+
assert_timer "action_controller.process_action.foo.bar"
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_logs_send_file
|
29
|
+
instrument "send_file"
|
30
|
+
|
31
|
+
assert_timer "action_controller.send_file.foo.bar"
|
32
|
+
end
|
33
|
+
|
34
|
+
def instrument(event)
|
35
|
+
super "#{event}.action_controller", { controller: 'foo', action: 'bar' }
|
36
|
+
end
|
37
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'harness/action_controller'
|
3
|
+
require 'minitest/unit'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
class MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
Harness.config.collector = Harness::FakeCollector.new
|
9
|
+
Harness.config.queue = Harness::SyncQueue.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_timer(name)
|
13
|
+
refute_empty timers
|
14
|
+
timer = timers.find { |t| t.name == name }
|
15
|
+
assert timer, "Timer #{name} not logged!"
|
16
|
+
end
|
17
|
+
|
18
|
+
def assert_increment(name)
|
19
|
+
refute_empty increments
|
20
|
+
increment = increments.find { |i| i.name == name }
|
21
|
+
assert increment, "Increment #{name} not logged!"
|
22
|
+
end
|
23
|
+
|
24
|
+
def assert_decrement(name)
|
25
|
+
refute_empty decrements
|
26
|
+
decrement = decrements.find { |i| i.name == name }
|
27
|
+
assert decrement, "decrement #{name} not logged!"
|
28
|
+
end
|
29
|
+
|
30
|
+
def assert_gauge(name)
|
31
|
+
refute_empty gauges
|
32
|
+
gauge = gauges.find { |g| g.name == name }
|
33
|
+
assert gauge, "gauge #{name} not logged!"
|
34
|
+
end
|
35
|
+
|
36
|
+
def instrument(name, data = {}, &block)
|
37
|
+
ActiveSupport::Notifications.instrument name, data, &block
|
38
|
+
end
|
39
|
+
|
40
|
+
def collector
|
41
|
+
Harness.config.collector
|
42
|
+
end
|
43
|
+
|
44
|
+
def timers
|
45
|
+
collector.timers
|
46
|
+
end
|
47
|
+
|
48
|
+
def increments
|
49
|
+
collector.increments
|
50
|
+
end
|
51
|
+
|
52
|
+
def decrements
|
53
|
+
collector.decrements
|
54
|
+
end
|
55
|
+
|
56
|
+
def counters
|
57
|
+
collector.counters
|
58
|
+
end
|
59
|
+
|
60
|
+
def gauges
|
61
|
+
collector.gauges
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: harness-actioncontroller
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ahawkins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: harness
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Foward ActionController's internal metrics to Harness
|
56
|
+
email:
|
57
|
+
- adam@hawkins.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- harness-acioncontroller.gemspec
|
68
|
+
- lib/harness-actioncontroller.rb
|
69
|
+
- lib/harness/action_controller.rb
|
70
|
+
- lib/harness/actioncontroller/version.rb
|
71
|
+
- test/action_controller_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: ''
|
97
|
+
test_files:
|
98
|
+
- test/action_controller_test.rb
|
99
|
+
- test/test_helper.rb
|