stackify-ruby-apm 1.13.2 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1ee1b9b91d78729820e74b7fbc014310af4037390de6c0982cb0169cba50a8a
4
- data.tar.gz: 3a7dfe377099f033779e85d591e8ec973039ee4a4b59f20175e57afdd967819a
3
+ metadata.gz: 76953d4e093b082edd18b9b64c80f282cef005ca138ded983b5bc88b1545db96
4
+ data.tar.gz: 3c1fba2fa393369d38de568f91dbec9d1708a963c5f3802719f285c2e99edefa
5
5
  SHA512:
6
- metadata.gz: 143b1fba17994c286ad71dc020d731247079b28a75fda11ee742ed8d49c023557a731e16c0ae8715153d6f5c98dbbb7dbbdaa10a225d4ad8f5f0750aedb7a739
7
- data.tar.gz: 28be6a1c40fa6dab5fc5a35f2c56e99984c579d4e5f84e5481ffa6e5c9b9fa9c615a0425c1af81d5a3d1d7d4088df1b4f777250fde816b48a2049f320a1df1c4
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)
@@ -25,6 +25,7 @@ module StackifyRubyAPM
25
25
  CATEGORY: 'Database',
26
26
  SUBCATEGORY: 'DynamoDB',
27
27
  ACTION: operation_name,
28
+ URL: self.config.endpoint,
28
29
  )
29
30
  rescue Exception => e
30
31
  StackifyRubyAPM.agent.error "[DynamoDBSpy] Error: creating span context."
@@ -55,7 +55,9 @@ module StackifyRubyAPM
55
55
  #
56
56
  ctx = Span::Context.new(
57
57
  CATEGORY: 'MongoDB',
58
- MONGODB_COLLECTION: col
58
+ MONGODB_COLLECTION: col,
59
+ OPERATION: event.command_name.to_s,
60
+ URL: event.address.to_s
59
61
  )
60
62
 
61
63
  # Creates new span from Mongo event
@@ -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
- redis_nspace = !redis_details.blank? ? redis_details[0] : ''
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 !redis_details.blank? && redis_details[1]
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Sets the version of the APM
4
4
  module StackifyRubyAPM
5
- VERSION = '1.13.2'.freeze
5
+ VERSION = '1.14.0'.freeze
6
6
  end
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.13.2
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-01 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails