stackify-ruby-apm 1.17.0 → 1.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stackify_apm/normalizers/active_record.rb +32 -39
- 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: 95f66de5cfc9c86486d1d9be9083f3d86300ee9d546ee23c56a493bb99ab8fbf
|
4
|
+
data.tar.gz: ead544f89afaab3ccd1f77f249eff2cc76815353b4eb5ca8bd680937c4fa07da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e949476ed9c2b35420f574850c5e52086ff7f5c617a09728d62a2449bcc0b6d93af75271bf800b7718dcea122ebe819b8f9d0316d97e78b667667393dc99df
|
7
|
+
data.tar.gz: de9e2587b22f07aea878e714153ee19d60efe7a397363d2df5cdeed96051f62a4797580a61b83a41c3adde28446c1e1bf7f604afd30a5ba1bd662052e466c5ad
|
@@ -20,21 +20,22 @@ module StackifyRubyAPM
|
|
20
20
|
def normalize(_transaction, _name, payload)
|
21
21
|
return :skip if %w[SCHEMA CACHE].include?(payload[:name])
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
adapter = lookup_adapter(payload)
|
24
|
+
statement = query_variables(payload, adapter)
|
25
|
+
check_prepared_stmt(statement, payload, adapter)
|
25
26
|
name = payload[:sql] || payload[:name] || 'Default'
|
26
27
|
context = Span::Context.new(statement)
|
27
28
|
|
28
|
-
type = format('db.%s.sql',
|
29
|
+
type = format('db.%s.sql', adapter || 'unknown').freeze
|
29
30
|
[name, type, context]
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
33
34
|
|
34
|
-
def query_variables(payload)
|
35
|
+
def query_variables(payload, adapter)
|
35
36
|
adapter_config = lookup_adapter_config
|
36
37
|
props = get_common_db_properties
|
37
|
-
props[:PROVIDER] = get_profiler(
|
38
|
+
props[:PROVIDER] = get_profiler(adapter)
|
38
39
|
props[:SQL] = payload[:sql]
|
39
40
|
if adapter_config
|
40
41
|
props[:URL] = "#{adapter_config[:host]}:#{adapter_config[:port]}"
|
@@ -58,52 +59,44 @@ module StackifyRubyAPM
|
|
58
59
|
# Handler Retrieve Connection: lib/active_record/connection_adapters/abstract/connection_pool.rb#L1111
|
59
60
|
|
60
61
|
def lookup_adapter(payload)
|
61
|
-
connection
|
62
|
+
# If connection is explicitly set
|
62
63
|
if (payload.key?(:connection))
|
63
64
|
connection = payload[:connection]
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
connections.
|
74
|
-
if
|
75
|
-
connection =
|
65
|
+
if (connection.respond_to?(:adapter_name) && !connection.adapter_name.nil?)
|
66
|
+
return connection.adapter_name.downcase
|
67
|
+
end
|
68
|
+
elsif ::ActiveRecord::Base.respond_to?(:connection_handler) && ::ActiveRecord::Base.connection_handler.connection_pool_list.size() > 0 && payload.key?(:connection_id)
|
69
|
+
connection_id = payload[:connection_id]
|
70
|
+
connection = nil
|
71
|
+
connection_pool = nil
|
72
|
+
connection_pool_list = ::ActiveRecord::Base.connection_handler.connection_pool_list
|
73
|
+
connection_pool_list.each do |pool|
|
74
|
+
pool.instance_variable_get(:@connections).each do |conn|
|
75
|
+
if conn.object_id == connection_id
|
76
|
+
connection = conn
|
76
77
|
break
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
80
|
-
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
return ::ActiveRecord::Base.connection.adapter_name.downcase
|
85
|
-
else
|
86
|
-
return 'generic'
|
82
|
+
if (!connection.nil? && connection.respond_to?(:adapter_name))
|
83
|
+
return connection.adapter_name.downcase
|
87
84
|
end
|
88
85
|
end
|
89
|
-
|
90
|
-
|
91
|
-
if
|
92
|
-
return
|
93
|
-
|
94
|
-
|
86
|
+
if (::ActiveRecord::Base.respond_to?(:connection_pool) && ::ActiveRecord::Base.connection_pool)
|
87
|
+
base_connection_pool = ::ActiveRecord::Base.connection_pool
|
88
|
+
if (base_connection_pool.respond_to?(:config))
|
89
|
+
return base_connection_pool.config[:adapter]
|
90
|
+
end
|
91
|
+
if (base_connection_pool.respond_to?(:db_config))
|
92
|
+
return base_connection_pool.db_config[:adapter]
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
98
|
-
|
96
|
+
return 'generic'
|
99
97
|
rescue StandardError => error
|
100
98
|
debug '[SqlNormalizer] lookup_adapter err: ' + error.inspect.to_s
|
101
|
-
|
102
|
-
if ::ActiveRecord::Base.respond_to?(:connection)
|
103
|
-
::ActiveRecord::Base.connection.adapter_name.downcase
|
104
|
-
else
|
105
|
-
nil
|
106
|
-
end
|
99
|
+
return 'generic'
|
107
100
|
end
|
108
101
|
|
109
102
|
def lookup_adapter_config
|
@@ -121,9 +114,9 @@ module StackifyRubyAPM
|
|
121
114
|
nil
|
122
115
|
end
|
123
116
|
|
124
|
-
def check_prepared_stmt(statement, payload)
|
117
|
+
def check_prepared_stmt(statement, payload, adapter)
|
125
118
|
if StackifyRubyAPM.agent.config.prefix_enabled
|
126
|
-
case get_profiler(
|
119
|
+
case get_profiler(adapter)
|
127
120
|
when 'generic', 'mysql', 'sqlite', 'oracle', 'db2'
|
128
121
|
check_prepared_stmt_by_placeholder(payload[:sql].include?('?'), statement, payload)
|
129
122
|
when 'postgresql'
|
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.17.
|
4
|
+
version: 1.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stackify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|