activerecord-instrumentation 0.6.0.jhemphill1 → 0.6.0.jhemphill4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +11 -11
- data/lib/active_record/open_tracing/processor.rb +32 -19
- data/lib/active_record/open_tracing/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fceef2796a103f493c939152dcdaa4428111c082e3908354abfbe04b1614f16
|
4
|
+
data.tar.gz: ef23a8d9a4fe682d7dfd5c6d23b8bb45fd188917240d79b27fa1417c56522c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d78da8a4bb59a1f917d94b65bc5c7cdb75a16de16220727ef21ae4c03cf0ba7fa7d12a8d4a266af693cc4971c91b78e8327550f0cc254b169c1da76446b012
|
7
|
+
data.tar.gz: 33b0aa8435da2e6aa7d9877d1019feb37d9d984a39a2906d6dfd614fc26f75afdb53d1bad0782a558e3d8472b621be76abca53c2fc4df87a2fa7c3a27a8060ee
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activerecord-instrumentation (0.6.0.
|
4
|
+
activerecord-instrumentation (0.6.0.jhemphill4)
|
5
5
|
activerecord
|
6
6
|
opentracing (~> 0.5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (6.1.
|
12
|
-
activesupport (= 6.1.
|
13
|
-
activerecord (6.1.
|
14
|
-
activemodel (= 6.1.
|
15
|
-
activesupport (= 6.1.
|
16
|
-
activesupport (6.1.
|
11
|
+
activemodel (6.1.6.1)
|
12
|
+
activesupport (= 6.1.6.1)
|
13
|
+
activerecord (6.1.6.1)
|
14
|
+
activemodel (= 6.1.6.1)
|
15
|
+
activesupport (= 6.1.6.1)
|
16
|
+
activesupport (6.1.6.1)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
zeitwerk (~> 2.3)
|
22
22
|
ast (2.4.0)
|
23
|
-
concurrent-ruby (1.1.
|
23
|
+
concurrent-ruby (1.1.10)
|
24
24
|
diff-lcs (1.3)
|
25
|
-
i18n (1.
|
25
|
+
i18n (1.11.0)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
27
|
jaro_winkler (1.5.4)
|
28
|
-
minitest (5.
|
28
|
+
minitest (5.16.2)
|
29
29
|
opentracing (0.5.0)
|
30
30
|
opentracing_test_tracer (0.1.1)
|
31
31
|
opentracing
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
tzinfo (2.0.4)
|
67
67
|
concurrent-ruby (~> 1.0)
|
68
68
|
unicode-display_width (1.6.1)
|
69
|
-
zeitwerk (2.
|
69
|
+
zeitwerk (2.6.0)
|
70
70
|
|
71
71
|
PLATFORMS
|
72
72
|
ruby
|
@@ -73,13 +73,16 @@ module ActiveRecord
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def tags_for_payload(payload)
|
76
|
+
db_config = connection_config(payload[:connection])
|
77
|
+
|
76
78
|
{
|
77
79
|
"component" => COMPONENT_NAME,
|
78
80
|
"span.kind" => SPAN_KIND,
|
79
81
|
"db.instance" => db_instance,
|
80
82
|
"db.cached" => payload.fetch(:cached, false),
|
81
83
|
"db.type" => DB_TYPE,
|
82
|
-
"peer.
|
84
|
+
"peer.mysql_db_name" => mysql_db_name_tag(payload.fetch(:connection, nil)&.raw_connection),
|
85
|
+
"peer.address" => peer_address_tag(db_config)
|
83
86
|
}.merge(db_statement(payload))
|
84
87
|
end
|
85
88
|
|
@@ -104,31 +107,41 @@ module ActiveRecord
|
|
104
107
|
sanitizer ? sanitizer.sanitize(sql) : sql
|
105
108
|
end
|
106
109
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
else
|
112
|
-
@peer_address_tag = [
|
113
|
-
"#{connection_config.fetch(:adapter)}://",
|
114
|
-
connection_config[:username],
|
115
|
-
connection_config[:host] && "@#{connection_config[:host]}",
|
116
|
-
"/#{db_instance}"
|
117
|
-
].join
|
118
|
-
end
|
119
|
-
end
|
110
|
+
def mysql_db_name_tag(db_connection)
|
111
|
+
return db_connection.host if db_connection.respond_to?(:host)
|
112
|
+
return nil
|
113
|
+
end
|
120
114
|
|
121
|
-
|
115
|
+
def peer_address_tag(config)
|
116
|
+
@peer_address_tag ||= [
|
117
|
+
"#{config.fetch(:adapter)}://",
|
118
|
+
config[:username],
|
119
|
+
config[:host] && "@#{config[:host]}",
|
120
|
+
"/#{db_instance}"
|
121
|
+
].join
|
122
122
|
end
|
123
123
|
|
124
124
|
def db_instance
|
125
125
|
@db_instance ||= connection_config.fetch(:database)
|
126
126
|
end
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
# If a connection is passed in, pull the db config options hash from it. This connection
|
129
|
+
# is likely to be attached to the query/query client. Fall back to the application level
|
130
|
+
# config. This change will show writer vs reader/replica dbs in spans when it is determined
|
131
|
+
# at the query level.
|
132
|
+
def connection_config(connection = nil)
|
133
|
+
unless defined? @connection_config
|
134
|
+
if connection.raw_connection && connection.raw_connection.respond_to?(:query_options)
|
135
|
+
# you have a mysql client
|
136
|
+
@connection_config = connection.raw_connection.query_options
|
137
|
+
else
|
138
|
+
# Rails 6.2 will deprecate ActiveRecord::Base.connection_config
|
139
|
+
@connection_config = ActiveRecord::Base.try(:connection_db_config)&.configuration_hash ||
|
140
|
+
ActiveRecord::Base.connection_config
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
@connection_config
|
132
145
|
end
|
133
146
|
end
|
134
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
4
|
+
version: 0.6.0.jhemphill4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-07-
|
12
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: 1.3.1
|
215
215
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.3.11
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: ActiveRecord OpenTracing intrumenter
|