rorvswild 0.3.4 → 0.3.5
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/README.md +1 -1
- data/lib/rorvswild.rb +26 -17
- data/lib/rorvswild/version.rb +1 -1
- data/rorvswild.gemspec +2 -2
- data/test/ror_vs_wild_test.rb +25 -3
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f3058ebf12d59185c06a6e58d0708b768cbbd5e
|
4
|
+
data.tar.gz: 180c22cf8f25b526509164cd053fad4ddda35376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c7a6ba4143a8a1c1060a2bbd5b2ebaac29d3f29eb8a44d54aba7e170008903c9ff8b9dae020b2236864ed8fa3a24ce76222aab4c99251929fd1765e001e22d2
|
7
|
+
data.tar.gz: e4daa2f6ed71388c9a935ea3d6757a426e25e93206c688887f5cb02d90355329e354c47306a62dff887ad3b942fd71cd9b9790bd67bafdbab1a4a3c26448ced1
|
data/README.md
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -14,13 +14,15 @@ module RorVsWild
|
|
14
14
|
return if !defined?(Rails)
|
15
15
|
Rails::Railtie.initializer "rorvswild.detect_config_file" do
|
16
16
|
if !RorVsWild.default_client && (path = Rails.root.join("config/rorvswild.yml")).exist?
|
17
|
-
RorVsWild.load_config_file(path
|
17
|
+
if config = RorVsWild.load_config_file(path)[Rails.env]
|
18
|
+
RorVsWild::Client.new(config.symbolize_keys)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
def self.load_config_file(path
|
23
|
-
|
24
|
+
def self.load_config_file(path)
|
25
|
+
YAML.load(ERB.new(path.read).result)
|
24
26
|
end
|
25
27
|
|
26
28
|
def self.register_default_client(client)
|
@@ -226,19 +228,16 @@ module RorVsWild
|
|
226
228
|
@data.delete(Thread.current.object_id)
|
227
229
|
end
|
228
230
|
|
231
|
+
MEANINGLESS_QUERIES = %w[BEGIN COMMIT].freeze
|
232
|
+
|
229
233
|
def push_query(query)
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
hash[:sql] = query[:sql]
|
235
|
-
end
|
236
|
-
hash[:runtime] += query[:runtime]
|
234
|
+
hash = queries.find { |hash| hash[:line] == query[:line] && hash[:file] == query[:file] }
|
235
|
+
queries << hash = {file: query[:file], line: query[:line], runtime: 0, times: 0} if !hash
|
236
|
+
hash[:runtime] += query[:runtime]
|
237
|
+
if !MEANINGLESS_QUERIES.include?(query[:sql])
|
237
238
|
hash[:times] += 1
|
238
|
-
|
239
|
-
query[:
|
240
|
-
query[:max_runtime] = query[:runtime]
|
241
|
-
queries << query
|
239
|
+
hash[:sql] ||= query[:sql]
|
240
|
+
hash[:plan] ||= query[:plan] if query[:plan]
|
242
241
|
end
|
243
242
|
end
|
244
243
|
|
@@ -275,11 +274,21 @@ module RorVsWild
|
|
275
274
|
post("/errors".freeze, error: hash)
|
276
275
|
end
|
277
276
|
|
278
|
-
|
277
|
+
def gem_home
|
278
|
+
if ENV["GEM_HOME"] && !ENV["GEM_HOME"].empty?
|
279
|
+
ENV["GEM_HOME"]
|
280
|
+
elsif ENV["GEM_PATH"] && !(first_gem_path = ENV["GEM_PATH"].split(":").first)
|
281
|
+
first_gem_path if first_gem_path && !first_gem_path.empty?
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def gem_home_regex
|
286
|
+
@gem_home_regex ||= gem_home ? /\A#{gem_home}/.freeze : /\/gems\//.freeze
|
287
|
+
end
|
279
288
|
|
280
289
|
def extract_most_relevant_location(stack)
|
281
|
-
location = stack.find { |str| str =~ app_root_regex && !(str =~
|
282
|
-
location ||= stack.find { |str| !(str =~
|
290
|
+
location = stack.find { |str| str =~ app_root_regex && !(str =~ gem_home_regex) } if app_root_regex
|
291
|
+
location ||= stack.find { |str| !(str =~ gem_home_regex) } if gem_home_regex
|
283
292
|
split_file_location(relative_path(location || stack.first))
|
284
293
|
end
|
285
294
|
|
data/lib/rorvswild/version.rb
CHANGED
data/rorvswild.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = RorVsWild::VERSION
|
9
9
|
spec.authors = ["Alexis Bernard"]
|
10
10
|
spec.email = ["alexis@bernard.io"]
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
11
|
+
spec.summary = "All-in-one monitoring for Ruby on Rails applications."
|
12
|
+
spec.description = "All-in-one monitoring for Ruby on Rails applications."
|
13
13
|
spec.homepage = "http://www.rorvswild.com"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/test/ror_vs_wild_test.rb
CHANGED
@@ -7,7 +7,7 @@ require "minitest/autorun"
|
|
7
7
|
require 'mocha/mini_test'
|
8
8
|
require "top_tests"
|
9
9
|
|
10
|
-
class RorVsWildTest <
|
10
|
+
class RorVsWildTest < Minitest::Test
|
11
11
|
include TopTests
|
12
12
|
|
13
13
|
def test_measure_code
|
@@ -79,12 +79,34 @@ class RorVsWildTest < MiniTest::Unit::TestCase
|
|
79
79
|
assert_equal(["/app/models/user.rb", "3", "method3"], client.send(:extract_most_relevant_location, callstack))
|
80
80
|
end
|
81
81
|
|
82
|
+
def test_extract_most_relevant_location_when_gem_path_is_set_instead_of_gem_home
|
83
|
+
original_gem_home, original_gem_path = ENV["GEM_HOME"], ENV["GEM_PATH"]
|
84
|
+
ENV["GEM_HOME"], ENV["GEM_PATH"] = "", "/gem/path"
|
85
|
+
|
86
|
+
callstack = ["/gem/path/lib/sql.rb:1:in `method1'", "/usr/lib/ruby/net/http.rb:2:in `method2'", "/rails/root/app/models/user.rb:3:in `method3'"]
|
87
|
+
assert_equal(%w[/app/models/user.rb 3 method3], client.send(:extract_most_relevant_location, callstack))
|
88
|
+
ensure
|
89
|
+
ENV["GEM_HOME"], ENV["GEM_PATH"] = original_gem_home, original_gem_path
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_extract_most_relevant_location_when_gem_path_and_gem_home_are_undefined
|
93
|
+
original_gem_home, original_gem_path = ENV["GEM_HOME"], ENV["GEM_PATH"]
|
94
|
+
ENV["GEM_HOME"], ENV["GEM_PATH"] = "", ""
|
95
|
+
|
96
|
+
callstack = ["/gem/path/lib/sql.rb:1:in `method1'", "/usr/lib/ruby/net/http.rb:2:in `method2'", "/rails/root/app/models/user.rb:3:in `method3'"]
|
97
|
+
assert_equal(%w[/app/models/user.rb 3 method3], client.send(:extract_most_relevant_location, callstack))
|
98
|
+
ensure
|
99
|
+
ENV["GEM_HOME"], ENV["GEM_PATH"] = original_gem_home, original_gem_path
|
100
|
+
end
|
101
|
+
|
82
102
|
def test_push_query
|
83
103
|
client = initialize_client
|
84
104
|
client.send(:data)[:queries] = []
|
105
|
+
client.send(:push_query, {file: "file", line: 123, sql: "BEGIN", runtime: 10})
|
106
|
+
client.send(:push_query, {file: "file", line: 123, sql: "SELECT 1", runtime: 10})
|
85
107
|
client.send(:push_query, {file: "file", line: 123, sql: "SELECT 1", runtime: 10})
|
86
|
-
client.send(:push_query, {file: "file", line: 123, sql: "
|
87
|
-
assert_equal([{file: "file", line: 123, sql: "SELECT
|
108
|
+
client.send(:push_query, {file: "file", line: 123, sql: "COMMIT", runtime: 10})
|
109
|
+
assert_equal([{file: "file", line: 123, sql: "SELECT 1", runtime: 40, times: 2}], client.send(:queries))
|
88
110
|
end
|
89
111
|
|
90
112
|
def test_after_exception
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,8 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
-
description:
|
28
|
-
no time to waste.
|
27
|
+
description: All-in-one monitoring for Ruby on Rails applications.
|
29
28
|
email:
|
30
29
|
- alexis@bernard.io
|
31
30
|
executables: []
|
@@ -62,10 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
61
|
version: '0'
|
63
62
|
requirements: []
|
64
63
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.4.8
|
66
65
|
signing_key:
|
67
66
|
specification_version: 4
|
68
|
-
summary:
|
69
|
-
no time to waste.
|
67
|
+
summary: All-in-one monitoring for Ruby on Rails applications.
|
70
68
|
test_files:
|
71
69
|
- test/ror_vs_wild_test.rb
|