harness-sequel 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 +29 -0
- data/Rakefile +9 -0
- data/harness-sequel.gemspec +27 -0
- data/integration.rb +1 -0
- data/lib/harness-sequel.rb +2 -0
- data/lib/harness/sequel.rb +6 -0
- data/lib/harness/sequel/version.rb +5 -0
- data/lib/sequel/extensions/harness.rb +51 -0
- data/test/sequel_test.rb +66 -0
- data/test/test_helper.rb +63 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1c79613e8c08456d00becfb1b6731a3d7094267
|
4
|
+
data.tar.gz: 517cb08ffb8b217fa67d9ec34b11a72d0608f7a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c6403cb0f0280336925c5471456dd2a7a1e9a37507e258323c22eac653102a31368538fbf8d3d54bb32d15a9b671a2670971089fb7c660b9763f27dba4d5659
|
7
|
+
data.tar.gz: 1f42eca28c86e4c94ac2389377b70524a3388f1654713ed1ead57b73f823cee1672752499230b49c7b1e469388f99e1ab92f44e8df5af047c6f23b06a5c9fa76
|
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,29 @@
|
|
1
|
+
# Harness::Varnish
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'harness-varnish'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install harness-varnish
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'harness/sequel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "harness-sequel"
|
8
|
+
spec.version = Harness::Sequel::VERSION
|
9
|
+
spec.authors = ["ahawkins"]
|
10
|
+
spec.email = ["adam@hawkins.io"]
|
11
|
+
spec.description = %q{Report sequel performance metrics to Harness}
|
12
|
+
spec.summary = %q{}
|
13
|
+
spec.homepage = "https://github.com/ahawkins/harness-sequel"
|
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
|
+
spec.add_dependency "sequel"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
end
|
data/integration.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Sequel.extension :harness_instrumentation
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'active_support/core_ext/module'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module Sequel
|
5
|
+
class Database
|
6
|
+
class NullLogger < Logger
|
7
|
+
def initialize(*args)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(*args)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def null_logger
|
17
|
+
@null_logger ||= NullLogger.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def log_yield_with_instrument(sql, args = nil, &block)
|
21
|
+
@loggers << null_logger if @loggers.empty?
|
22
|
+
log_yield_without_instrument sql, args, &block
|
23
|
+
end
|
24
|
+
alias_method_chain :log_yield, :instrument
|
25
|
+
|
26
|
+
def log_duration_with_instrumentation(time, sql)
|
27
|
+
duration = time / 1000
|
28
|
+
|
29
|
+
Harness.timing 'sequel.query', duration
|
30
|
+
|
31
|
+
op = sql[0..5]
|
32
|
+
case op
|
33
|
+
when 'SELECT'
|
34
|
+
Harness.timing 'sequel.select', duration
|
35
|
+
Harness.timing 'sequel.read', duration
|
36
|
+
when 'UPDATE'
|
37
|
+
Harness.timing 'sequel.update', duration
|
38
|
+
Harness.timing 'sequel.write', duration
|
39
|
+
when 'INSERT'
|
40
|
+
Harness.timing 'sequel.insert', duration
|
41
|
+
Harness.timing 'sequel.write', duration
|
42
|
+
when 'DELETE'
|
43
|
+
Harness.timing 'sequel.delete', duration
|
44
|
+
Harness.timing 'sequel.write', duration
|
45
|
+
end
|
46
|
+
|
47
|
+
log_duration_without_instrumentation duration, sql
|
48
|
+
end
|
49
|
+
alias_method_chain :log_duration, :instrumentation
|
50
|
+
end
|
51
|
+
end
|
data/test/sequel_test.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class SequelIntegrationTest < MiniTest::Unit::TestCase
|
4
|
+
attr_reader :db
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@db = Sequel.sqlite
|
10
|
+
|
11
|
+
db.create_table :items do
|
12
|
+
primary_key :id
|
13
|
+
String :name
|
14
|
+
Float :price
|
15
|
+
end
|
16
|
+
|
17
|
+
counters.clear
|
18
|
+
increments.clear
|
19
|
+
gauges.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_reports_queries_as_counters_and_timers
|
23
|
+
db[:items].all
|
24
|
+
assert_timer "sequel.query"
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_reports_selects_as_reads
|
28
|
+
db[:items].all
|
29
|
+
assert_timer "sequel.read"
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_reports_select_as_own_stat
|
33
|
+
db[:items].all
|
34
|
+
assert_timer "sequel.select"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_reports_inserts_as_writes
|
38
|
+
db[:items].insert name: 'abc', price: 5
|
39
|
+
assert_timer "sequel.write"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_reports_inserts_as_own_stat
|
43
|
+
db[:items].insert name: 'test', price: 5
|
44
|
+
assert_timer "sequel.insert"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_reports_updates_as_writes
|
48
|
+
db[:items].update name: 'abc', price: 5
|
49
|
+
assert_timer "sequel.write"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_reports_updates_as_own_stat
|
53
|
+
db[:items].update name: 'test', price: 5
|
54
|
+
assert_timer "sequel.update"
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_reports_deletes_as_writes
|
58
|
+
db[:items].delete
|
59
|
+
assert_timer "sequel.write"
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_reports_deletes_as_own_stat
|
63
|
+
db[:items].delete
|
64
|
+
assert_timer "sequel.delete"
|
65
|
+
end
|
66
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'harness-sequel'
|
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,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: harness-sequel
|
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-10-10 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: sequel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Report sequel performance metrics to Harness
|
84
|
+
email:
|
85
|
+
- adam@hawkins.io
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- harness-sequel.gemspec
|
96
|
+
- integration.rb
|
97
|
+
- lib/harness-sequel.rb
|
98
|
+
- lib/harness/sequel.rb
|
99
|
+
- lib/harness/sequel/version.rb
|
100
|
+
- lib/sequel/extensions/harness.rb
|
101
|
+
- test/sequel_test.rb
|
102
|
+
- test/test_helper.rb
|
103
|
+
homepage: https://github.com/ahawkins/harness-sequel
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: ''
|
127
|
+
test_files:
|
128
|
+
- test/sequel_test.rb
|
129
|
+
- test/test_helper.rb
|