shiba 0.1.2 → 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.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/.travis/my.cnf +3 -0
- data/Gemfile.lock +14 -1
- data/README.md +93 -30
- data/Rakefile +9 -1
- data/TODO +25 -7
- data/bin/check +0 -0
- data/bin/dump_stats +38 -0
- data/bin/explain +67 -28
- data/bin/shiba +4 -4
- data/lib/shiba.rb +3 -1
- data/lib/shiba/analyzer.rb +6 -5
- data/lib/shiba/backtrace.rb +56 -0
- data/lib/shiba/checker.rb +103 -0
- data/lib/shiba/configure.rb +28 -8
- data/lib/shiba/diff.rb +119 -0
- data/lib/shiba/explain.rb +149 -49
- data/lib/shiba/fuzzer.rb +77 -0
- data/lib/shiba/index.rb +8 -129
- data/lib/shiba/index_stats.rb +210 -0
- data/lib/shiba/output.rb +24 -18
- data/lib/shiba/output/tags.yaml +34 -13
- data/lib/shiba/query_watcher.rb +3 -46
- data/lib/shiba/railtie.rb +31 -8
- data/lib/shiba/table_stats.rb +34 -0
- data/lib/shiba/version.rb +1 -1
- data/shiba.gemspec +1 -0
- data/shiba.yml.example +4 -0
- data/web/main.css +32 -2
- data/web/results.html.erb +132 -58
- metadata +26 -6
- data/bin/analyze +0 -77
- data/bin/inspect +0 -0
- data/bin/parse +0 -0
- data/bin/watch.rb +0 -19
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shiba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Osheroff
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-02-
|
12
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: bundler
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,24 +64,23 @@ extensions: []
|
|
50
64
|
extra_rdoc_files: []
|
51
65
|
files:
|
52
66
|
- ".gitignore"
|
67
|
+
- ".travis.yml"
|
68
|
+
- ".travis/my.cnf"
|
53
69
|
- CODE_OF_CONDUCT.md
|
54
70
|
- Gemfile
|
55
71
|
- Gemfile.lock
|
56
72
|
- README.md
|
57
73
|
- Rakefile
|
58
74
|
- TODO
|
59
|
-
- bin/analyze
|
60
75
|
- bin/check
|
61
76
|
- bin/console
|
77
|
+
- bin/dump_stats
|
62
78
|
- bin/explain
|
63
79
|
- bin/fingerprint
|
64
|
-
- bin/inspect
|
65
|
-
- bin/parse
|
66
80
|
- bin/redmine/sample_redmine.rb
|
67
81
|
- bin/release
|
68
82
|
- bin/setup
|
69
83
|
- bin/shiba
|
70
|
-
- bin/watch.rb
|
71
84
|
- cmd/builds/fingerprint.darwin-amd64
|
72
85
|
- cmd/builds/fingerprint.linux-amd64
|
73
86
|
- cmd/check.go
|
@@ -76,16 +89,23 @@ files:
|
|
76
89
|
- cmd/parse.go
|
77
90
|
- lib/shiba.rb
|
78
91
|
- lib/shiba/analyzer.rb
|
92
|
+
- lib/shiba/backtrace.rb
|
93
|
+
- lib/shiba/checker.rb
|
79
94
|
- lib/shiba/configure.rb
|
95
|
+
- lib/shiba/diff.rb
|
80
96
|
- lib/shiba/explain.rb
|
97
|
+
- lib/shiba/fuzzer.rb
|
81
98
|
- lib/shiba/index.rb
|
99
|
+
- lib/shiba/index_stats.rb
|
82
100
|
- lib/shiba/output.rb
|
83
101
|
- lib/shiba/output/tags.yaml
|
84
102
|
- lib/shiba/query.rb
|
85
103
|
- lib/shiba/query_watcher.rb
|
86
104
|
- lib/shiba/railtie.rb
|
105
|
+
- lib/shiba/table_stats.rb
|
87
106
|
- lib/shiba/version.rb
|
88
107
|
- shiba.gemspec
|
108
|
+
- shiba.yml.example
|
89
109
|
- web/bootstrap.min.css
|
90
110
|
- web/dist/bundle.js
|
91
111
|
- web/main.css
|
data/bin/analyze
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#!/usr/bin/env ruby
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
require 'optionparser'
|
7
|
-
require 'shiba'
|
8
|
-
require 'shiba/configure'
|
9
|
-
require 'shiba/output'
|
10
|
-
|
11
|
-
options = {}
|
12
|
-
|
13
|
-
parser = Shiba::Configure.make_options_parser(options)
|
14
|
-
parser.banner = "analyze <command>. Creates report of SQL from the running process."
|
15
|
-
parser.parse!
|
16
|
-
|
17
|
-
if options["test"] && !options["file"]
|
18
|
-
$stderr.puts "--file <query log> is required for test mode"
|
19
|
-
$stderr.puts parser.banner
|
20
|
-
exit 1
|
21
|
-
end
|
22
|
-
|
23
|
-
# Automagic configuration goes here
|
24
|
-
if !options["database"]
|
25
|
-
config = Shiba::Configure.activerecord_configuration
|
26
|
-
|
27
|
-
if tc = config && config['test']
|
28
|
-
$stderr.puts "Reading configuration from '#{`pwd`.chomp}/config/database.yml'[:test]."
|
29
|
-
options['host'] ||= tc['host']
|
30
|
-
options['database'] ||= tc['database']
|
31
|
-
options['username'] ||= tc['username']
|
32
|
-
options['password'] ||= tc['password']
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Shiba.configure(options)
|
37
|
-
|
38
|
-
if !options["file"]
|
39
|
-
options["file"] = `mktemp /tmp/shiba-query.log-#{Time.now.to_i}`.chomp
|
40
|
-
end
|
41
|
-
|
42
|
-
if !options["explain"]
|
43
|
-
options["explain"] = `mktemp /tmp/shiba-explain.log-#{Time.now.to_i}`.chomp
|
44
|
-
end
|
45
|
-
|
46
|
-
# Log process queries
|
47
|
-
if !options.delete("test")
|
48
|
-
if ARGV.empty?
|
49
|
-
$stderr.puts "The name of a command must be passed in to generate SQL logs."
|
50
|
-
$stderr.puts "Example: shiba analyze rake spec"
|
51
|
-
$stderr.puts ""
|
52
|
-
$stderr.puts "For static analysis, try the --test option."
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
|
56
|
-
path = "#{File.dirname(__FILE__)}/watch.rb"
|
57
|
-
watch_args = ARGV + [ "--file", options["file"] ]
|
58
|
-
pid = fork do
|
59
|
-
Signal.trap("INT") { exit 1 }
|
60
|
-
exec(path, *watch_args)
|
61
|
-
end
|
62
|
-
|
63
|
-
Signal.trap("INT", "IGNORE")
|
64
|
-
Process.wait(pid)
|
65
|
-
Signal.trap("INT", "DEFAULT")
|
66
|
-
end
|
67
|
-
|
68
|
-
# Explain
|
69
|
-
$stderr.puts "Analyzing SQL to '#{options["explain"]}'..."
|
70
|
-
path = "#{File.dirname(__FILE__)}/explain"
|
71
|
-
args = options.select { |_,v| !v.nil? }.map { |k,v| [ "--#{k}", v ] }.flatten
|
72
|
-
|
73
|
-
$stderr.puts ([path] + args).join(" ")
|
74
|
-
if !system(path, *args)
|
75
|
-
exit 1
|
76
|
-
end
|
77
|
-
|
data/bin/inspect
DELETED
Binary file
|
data/bin/parse
DELETED
Binary file
|
data/bin/watch.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'optionparser'
|
4
|
-
|
5
|
-
options = {}
|
6
|
-
parser = OptionParser.new do |opts|
|
7
|
-
opts.banner = "watch <command>. Create SQL logs for a running process"
|
8
|
-
|
9
|
-
opts.on("-f", "--file FILE", "write to file") do |f|
|
10
|
-
options["file"] = f
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
parser.parse!
|
16
|
-
|
17
|
-
$stderr.puts "Recording SQL queries to '#{options["file"]}'..."
|
18
|
-
ENV['SHIBA_OUT'] = options["file"]
|
19
|
-
Kernel.exec(ARGV.join(" "))
|