activerecord-instrumentation 0.6.0.jhemphill1 → 0.6.0.jhemphill4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f9fe8e655275c95316af6091d55c794c384c20b721c301056661aa4eca8aafd
4
- data.tar.gz: 128ba9528fdc517e3fddfab4ad75cad0cfea8fd4f4dab7f371cfd0b7c79c5699
3
+ metadata.gz: 5fceef2796a103f493c939152dcdaa4428111c082e3908354abfbe04b1614f16
4
+ data.tar.gz: ef23a8d9a4fe682d7dfd5c6d23b8bb45fd188917240d79b27fa1417c56522c90
5
5
  SHA512:
6
- metadata.gz: 1b3b8da9054b12445889993ee125a3ef456ff97f056ef3ee6194d3bfc100eb263401335e797681334dd58745bc3d9108110bf3b2aa9e69212d25f68a9e840a03
7
- data.tar.gz: de602d96113006ff75dbaf44a497289f5fcc193b1fd8a5797a35c3a4bfafa65a546effd7152db406ca901dfc738bae538ef214c24a485888ac9a96e52bf4b668
6
+ metadata.gz: 70d78da8a4bb59a1f917d94b65bc5c7cdb75a16de16220727ef21ae4c03cf0ba7fa7d12a8d4a266af693cc4971c91b78e8327550f0cc254b169c1da76446b012
7
+ data.tar.gz: 33b0aa8435da2e6aa7d9877d1019feb37d9d984a39a2906d6dfd614fc26f75afdb53d1bad0782a558e3d8472b621be76abca53c2fc4df87a2fa7c3a27a8060ee
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 0.6.0.jhemphill4 07/11/2022
5
+ * Fixed query tagging for empty queries
6
+
4
7
  ## 0.5.2 01/24/2022
5
8
  * Fixed query tagging for empty queries
6
9
 
data/Gemfile.lock CHANGED
@@ -1,31 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-instrumentation (0.6.0.jhemphill1)
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.4.4)
12
- activesupport (= 6.1.4.4)
13
- activerecord (6.1.4.4)
14
- activemodel (= 6.1.4.4)
15
- activesupport (= 6.1.4.4)
16
- activesupport (6.1.4.4)
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.9)
23
+ concurrent-ruby (1.1.10)
24
24
  diff-lcs (1.3)
25
- i18n (1.10.0)
25
+ i18n (1.11.0)
26
26
  concurrent-ruby (~> 1.0)
27
27
  jaro_winkler (1.5.4)
28
- minitest (5.15.0)
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.5.4)
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.address" => peer_address_tag(payload.fetch(:connection, false))
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 peer_address_tag(connection)
108
- unless defined? @peer_address_tag
109
- if connection.respond_to? :host # using the postgres adapter
110
- @peer_address_tag = connection.host
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
- @peer_address_tag
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
- def connection_config
129
- # Rails 6.2 will deprecate ActiveRecord::Base.connection_config
130
- @connection_config ||=
131
- ActiveRecord::Base.try(:connection_db_config)&.configuration_hash || ActiveRecord::Base.connection_config
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module OpenTracing
5
- VERSION = "0.6.0.jhemphill1"
5
+ VERSION = "0.6.0.jhemphill4"
6
6
  end
7
7
  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.jhemphill1
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-11 00:00:00.000000000 Z
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.1.6
216
+ rubygems_version: 3.3.11
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: ActiveRecord OpenTracing intrumenter