scout_apm 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/lib/scout_apm/app_server_load.rb +2 -1
- data/lib/scout_apm/framework_integrations/rails_2.rb +7 -1
- data/lib/scout_apm/framework_integrations/rails_3_or_4.rb +4 -2
- data/lib/scout_apm/framework_integrations/ruby.rb +4 -0
- data/lib/scout_apm/framework_integrations/sinatra.rb +4 -0
- data/lib/scout_apm/instruments/mongoid.rb +76 -4
- data/lib/scout_apm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63ae601480e206eabc6a2a0f9d5b4a910ff1b96b
|
4
|
+
data.tar.gz: 62e2cc35685a98a5ecb13432166ad0b31e5957ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2de68e360bb022bfa74f2442f57fc84fc7914b084c3ef5c21870e79453197a7c2fb6744179f02d4ffbaabe4bbd265c586df0d9d3327f4a0628803bb11bf9de64
|
7
|
+
data.tar.gz: 876b496318c21489278202605167d6879636c8363247df4da87301b19625f8a9f691a1b6e71a6ed905ef3af12da2ebd103763fbbb2f3c2bc9b2fdb4a8d3bdaa3
|
data/CHANGELOG.markdown
CHANGED
@@ -34,7 +34,8 @@ module ScoutApm
|
|
34
34
|
:app_server => ScoutApm::Environment.instance.app_server,
|
35
35
|
:ruby_version => RUBY_VERSION,
|
36
36
|
:hostname => ScoutApm::Environment.instance.hostname,
|
37
|
-
:database_engine => ScoutApm::Environment.instance.database_engine,
|
37
|
+
:database_engine => ScoutApm::Environment.instance.database_engine, # Detected
|
38
|
+
:database_adapter => ScoutApm::Environment.instance.raw_database_adapter, # Raw
|
38
39
|
:application_name => ScoutApm::Environment.instance.application_name,
|
39
40
|
:libraries => ScoutApm::Utils::InstalledGems.new.run,
|
40
41
|
:paas => ScoutApm::Environment.instance.platform_integration.name
|
@@ -37,7 +37,6 @@ module ScoutApm
|
|
37
37
|
default = :mysql
|
38
38
|
|
39
39
|
if defined?(ActiveRecord::Base)
|
40
|
-
config = ActiveRecord::Base.configurations[env]
|
41
40
|
if config && config["adapter"]
|
42
41
|
case config["adapter"].to_s
|
43
42
|
when "postgres" then :postgres
|
@@ -45,6 +44,7 @@ module ScoutApm
|
|
45
44
|
when "postgis" then :postgres
|
46
45
|
when "sqlite3" then :sqlite
|
47
46
|
when "mysql" then :mysql
|
47
|
+
when "mysql2" then :mysql
|
48
48
|
else default
|
49
49
|
end
|
50
50
|
else
|
@@ -56,6 +56,12 @@ module ScoutApm
|
|
56
56
|
rescue
|
57
57
|
default
|
58
58
|
end
|
59
|
+
|
60
|
+
def raw_database_adapter
|
61
|
+
ActiveRecord::Base.configurations[env]["adapter"]
|
62
|
+
rescue
|
63
|
+
nil
|
64
|
+
end
|
59
65
|
end
|
60
66
|
end
|
61
67
|
end
|
@@ -37,14 +37,16 @@ module ScoutApm
|
|
37
37
|
default = :postgres
|
38
38
|
|
39
39
|
@database_engine = if defined?(ActiveRecord::Base)
|
40
|
-
adapter =
|
40
|
+
adapter = raw_database_adapter # can be nil
|
41
41
|
|
42
42
|
case adapter.to_s
|
43
43
|
when "postgres" then :postgres
|
44
44
|
when "postgresql" then :postgres
|
45
45
|
when "postgis" then :postgres
|
46
46
|
when "sqlite3" then :sqlite
|
47
|
+
when "sqlite" then :sqlite
|
47
48
|
when "mysql" then :mysql
|
49
|
+
when "mysql2" then :mysql
|
48
50
|
else default
|
49
51
|
end
|
50
52
|
else
|
@@ -53,7 +55,7 @@ module ScoutApm
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
58
|
+
def raw_database_adapter
|
57
59
|
adapter = if ActiveRecord::Base.respond_to?(:connection_config)
|
58
60
|
ActiveRecord::Base.connection_config[:adapter].to_s
|
59
61
|
else
|
@@ -19,14 +19,86 @@ module ScoutApm
|
|
19
19
|
if defined?(::Mongoid) and !defined?(::Moped)
|
20
20
|
ScoutApm::Agent.instance.logger.info "Instrumenting Mongoid"
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
### OLD (2.x) mongoids
|
23
|
+
if defined?(::Mongoid::Collection)
|
24
|
+
::Mongoid::Collection.class_eval do
|
25
|
+
include ScoutApm::Tracer
|
26
|
+
(::Mongoid::Collections::Operations::ALL - [:<<, :[]]).each do |method|
|
27
|
+
instrument_method method, :type => "MongoDB", :name => '#{@klass}/' + method.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
### See moped instrument for Moped driven deploys
|
33
|
+
|
34
|
+
### 5.x Mongoid
|
35
|
+
if mongoid_v5? && defined?(::Mongoid::Contextual::Mongo)
|
36
|
+
# All the public methods from Mongoid::Contextual::Mongo.
|
37
|
+
# TODO: Geo and MapReduce support (?). They are in other Contextual::* classes
|
38
|
+
methods = [
|
39
|
+
:count, :delete, :destroy, :distinct, :each,
|
40
|
+
:explain, :find_first, :find_one_and_delete, :find_one_and_replace,
|
41
|
+
:find_one_and_update, :first, :geo_near, :initialize, :last,
|
42
|
+
:length, :limit, :map, :map_reduce, :pluck,
|
43
|
+
:skip, :sort, :update, :update_all,
|
44
|
+
]
|
45
|
+
# :exists?,
|
46
|
+
|
47
|
+
methods.each do |method|
|
48
|
+
if ::Mongoid::Contextual::Mongo.method_defined?(method)
|
49
|
+
with_scout_instruments = %Q|
|
50
|
+
def #{method}_with_scout_instruments(*args)
|
51
|
+
|
52
|
+
req = ScoutApm::RequestManager.lookup
|
53
|
+
*db, collection = view.collection.namespace.split(".")
|
54
|
+
|
55
|
+
name = collection + "/#{method}"
|
56
|
+
filter = ScoutApm::Instruments::Mongoid.anonymize_filter(view.filter)
|
57
|
+
|
58
|
+
layer = ScoutApm::Layer.new("MongoDB", name)
|
59
|
+
layer.desc = filter.inspect
|
60
|
+
|
61
|
+
req.start_layer( layer )
|
62
|
+
begin
|
63
|
+
#{method}_without_scout_instruments
|
64
|
+
ensure
|
65
|
+
req.stop_layer
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
alias_method :#{method}_without_scout_instruments, :#{method}
|
70
|
+
alias_method :#{method}, :#{method}_with_scout_instruments
|
71
|
+
|
|
72
|
+
|
73
|
+
::Mongoid::Contextual::Mongo.class_eval(with_scout_instruments)
|
74
|
+
end
|
26
75
|
end
|
27
76
|
end
|
28
77
|
end
|
29
78
|
end
|
79
|
+
|
80
|
+
def mongoid_v5?
|
81
|
+
if defined?(::Mongoid::VERSION)
|
82
|
+
::Mongoid::VERSION =~ /\A5/
|
83
|
+
else
|
84
|
+
false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# Example of what a filter looks like: => {"founded"=>{"$gte"=>"1980-1-1"}, "name"=>{"$in"=>["Tool", "Deftones", "Melvins"]}}
|
90
|
+
# Approach: find every leaf-node, clear it. inspect the whole thing when done.
|
91
|
+
def self.anonymize_filter(filter)
|
92
|
+
Hash[
|
93
|
+
filter.map do |k,v|
|
94
|
+
if v.is_a? Hash
|
95
|
+
[k, anonymize_filter(v)]
|
96
|
+
else
|
97
|
+
[k, "?"]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
]
|
101
|
+
end
|
30
102
|
end
|
31
103
|
end
|
32
104
|
end
|
data/lib/scout_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Haynes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|