stackify-ruby-apm 1.13.2 → 1.14.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/lib/stackify_apm/normalizers/active_record.rb +11 -0
- data/lib/stackify_apm/spies/dynamo_db.rb +1 -0
- data/lib/stackify_apm/spies/mongo.rb +3 -1
- data/lib/stackify_apm/spies/redis.rb +6 -3
- data/lib/stackify_apm/spies/sinatra_activerecord/mysql_adapter.rb +21 -0
- data/lib/stackify_apm/spies/sinatra_activerecord/postgresql_adapter.rb +8 -0
- data/lib/stackify_apm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76953d4e093b082edd18b9b64c80f282cef005ca138ded983b5bc88b1545db96
|
4
|
+
data.tar.gz: 3c1fba2fa393369d38de568f91dbec9d1708a963c5f3802719f285c2e99edefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b9b23f4c1b473fc45850f996701cc33703de8a6937297638d84603a4ce816b2e00cb318d73eca407e073f1f41403d82b9d1bc7305cf4623b47a53965d8b576
|
7
|
+
data.tar.gz: 517edbe2b9f8ff7e1c5c8ecb381f93fc39a28af406de5c6ec45b5ff3c99a113bd4833482f38f7944f1c542e2a027e2c581c5d36df45d8b1749aefcdc752050df
|
@@ -29,9 +29,13 @@ module StackifyRubyAPM
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def query_variables(payload)
|
32
|
+
adapter_config = lookup_adapter_config
|
32
33
|
props = get_common_db_properties
|
33
34
|
props[:PROVIDER] = get_profiler(lookup_adapter)
|
34
35
|
props[:SQL] = payload[:sql]
|
36
|
+
if adapter_config
|
37
|
+
props[:URL] = "#{adapter_config[:host]}:#{adapter_config[:port]}"
|
38
|
+
end
|
35
39
|
props
|
36
40
|
end
|
37
41
|
|
@@ -42,6 +46,13 @@ module StackifyRubyAPM
|
|
42
46
|
nil
|
43
47
|
end
|
44
48
|
|
49
|
+
def lookup_adapter_config
|
50
|
+
::ActiveRecord::Base.connection_config.to_h
|
51
|
+
rescue StandardError => error
|
52
|
+
debug '[SqlNormalizer] lookup_adapter_config err: ' + error.inspect.to_s
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
45
56
|
def check_prepared_stmt(statement, payload)
|
46
57
|
if StackifyRubyAPM.agent.config.prefix_enabled
|
47
58
|
case get_profiler(lookup_adapter)
|
@@ -18,11 +18,13 @@ module StackifyRubyAPM
|
|
18
18
|
name = command[0].upcase.to_s
|
19
19
|
type = 'db.redis'
|
20
20
|
redis_details = command[1].is_a?(String) ? command[1].split(':') : []
|
21
|
-
|
21
|
+
# use length instead of .blank?
|
22
|
+
# reason: will throw error if activesupport missing
|
23
|
+
redis_nspace = redis_details.length ? redis_details[0] : ''
|
22
24
|
redis_key = ''
|
23
25
|
|
24
26
|
# Checks CACHEKEY value
|
25
|
-
if
|
27
|
+
if redis_details.length && redis_details[1]
|
26
28
|
# Initially sets the CACHEKEY value
|
27
29
|
args = redis_details[1].split('/')
|
28
30
|
redis_key = args[0]
|
@@ -43,7 +45,8 @@ module StackifyRubyAPM
|
|
43
45
|
COMPONENT_CATEGORY: 'Cache',
|
44
46
|
COMPONENT_DETAIL: 'Execute',
|
45
47
|
THREAD_ID: Thread.current.object_id,
|
46
|
-
OPERATION: name
|
48
|
+
OPERATION: name,
|
49
|
+
URL: "#{self.options[:host]}:#{self.options[:port]}"
|
47
50
|
}.tap do |hash|
|
48
51
|
hash[:CACHEKEY] = redis_key unless redis_key.empty?
|
49
52
|
hash[:CACHENAME] = redis_nspace unless redis_nspace.empty?
|
@@ -10,6 +10,7 @@ module StackifyRubyAPM
|
|
10
10
|
# @api private
|
11
11
|
class MysqlAdapterSpy
|
12
12
|
TYPE = 'db.sinatra_active_record.sql'.freeze
|
13
|
+
DEFAULT_PORT = 3306
|
13
14
|
if ActiveRecord::VERSION::MAJOR.to_i >= 5
|
14
15
|
def install
|
15
16
|
ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements.class_eval do
|
@@ -79,6 +80,7 @@ module StackifyRubyAPM
|
|
79
80
|
props = get_common_db_properties
|
80
81
|
props[:PROVIDER] = 'mysql'
|
81
82
|
props[:SQL] = payload[:sql]
|
83
|
+
props[:URL] = get_host unless !get_host
|
82
84
|
props
|
83
85
|
end
|
84
86
|
|
@@ -87,6 +89,13 @@ module StackifyRubyAPM
|
|
87
89
|
check_prepared_stmt_by_placeholder(payload[:sql].include?('?'), statement, payload)
|
88
90
|
end
|
89
91
|
end
|
92
|
+
|
93
|
+
def get_host
|
94
|
+
query_options = self.raw_connection.query_options.to_h
|
95
|
+
"#{query_options[:host]}:#{query_options[:port] || DEFAULT_PORT}"
|
96
|
+
rescue StandardError => error
|
97
|
+
nil
|
98
|
+
end
|
90
99
|
end
|
91
100
|
end
|
92
101
|
else
|
@@ -112,6 +121,7 @@ module StackifyRubyAPM
|
|
112
121
|
SQL: sql,
|
113
122
|
PROVIDER: 'mysql'
|
114
123
|
)
|
124
|
+
ctx[:URL] = get_host unless !get_host
|
115
125
|
|
116
126
|
result = exec_query_without_apm(sql, name, binds)
|
117
127
|
|
@@ -135,6 +145,7 @@ module StackifyRubyAPM
|
|
135
145
|
SQL: sql,
|
136
146
|
PROVIDER: 'mysql'
|
137
147
|
)
|
148
|
+
ctx[:URL] = get_host unless !get_host
|
138
149
|
|
139
150
|
result = exec_delete_without_apm(sql, name, binds)
|
140
151
|
|
@@ -158,6 +169,7 @@ module StackifyRubyAPM
|
|
158
169
|
SQL: sql,
|
159
170
|
PROVIDER: 'mysql'
|
160
171
|
)
|
172
|
+
ctx[:URL] = get_host unless !get_host
|
161
173
|
|
162
174
|
result = exec_update_without_apm(sql, name, binds)
|
163
175
|
|
@@ -181,6 +193,7 @@ module StackifyRubyAPM
|
|
181
193
|
SQL: sql,
|
182
194
|
PROVIDER: 'mysql'
|
183
195
|
)
|
196
|
+
ctx[:URL] = get_host unless !get_host
|
184
197
|
|
185
198
|
result = exec_insert_without_apm(sql, name, binds, _pk = nil, _sequence_name = nil)
|
186
199
|
|
@@ -188,6 +201,14 @@ module StackifyRubyAPM
|
|
188
201
|
return result
|
189
202
|
end
|
190
203
|
end
|
204
|
+
|
205
|
+
def get_host
|
206
|
+
config = self.config.to_h
|
207
|
+
"#{config[:host]}:#{config[:port] || DEFAULT_PORT}"
|
208
|
+
rescue StandardError => error
|
209
|
+
nil
|
210
|
+
end
|
211
|
+
|
191
212
|
end
|
192
213
|
end
|
193
214
|
end
|
@@ -80,6 +80,7 @@ module StackifyRubyAPM
|
|
80
80
|
props = get_common_db_properties
|
81
81
|
props[:PROVIDER] = 'postgresql'
|
82
82
|
props[:SQL] = payload[:sql]
|
83
|
+
props[:URL] = get_host unless !get_host
|
83
84
|
props
|
84
85
|
end
|
85
86
|
|
@@ -88,6 +89,13 @@ module StackifyRubyAPM
|
|
88
89
|
check_prepared_stmt_by_placeholder(!!payload[:sql].match(/\$\d/), statement, payload)
|
89
90
|
end
|
90
91
|
end
|
92
|
+
|
93
|
+
def get_host
|
94
|
+
connection = self.raw_connection
|
95
|
+
"#{connection.host}:#{connection.port}"
|
96
|
+
rescue StandardError => error
|
97
|
+
nil
|
98
|
+
end
|
91
99
|
end
|
92
100
|
end
|
93
101
|
end
|
data/lib/stackify_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackify-ruby-apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stackify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|