activerecord-instrumentation 0.6.0.jhemphill2 → 0.6.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: 29ef8227c4292b15e644ab1b59e56c28d48d97e36fe7be95862678bae61e5d9c
4
- data.tar.gz: 0e1efa52bb4a69a41b219028e8a25d9b21a67026c138d08c4b05b4bf72ab85bd
3
+ metadata.gz: 6ce6d77768f0c5c8ee3b9bc7459c840900d022ef672fb78f9342163bcfdee7ae
4
+ data.tar.gz: 5e73e0e111b40319e11326fe2247980daac4db510424b2d6c39452cba0f6fc06
5
5
  SHA512:
6
- metadata.gz: fc2935010852dca0b75cc17d3add77c3257a7b636117eb0fd58e19cb06132d6f2475bc9ecf02964e970625b2660b51f4d1e8eeb8b9265d693b7fc835c34654e4
7
- data.tar.gz: a7368790d1e844bf6b47812b50c2b439081c79648869f1eaf0dfba6e573568b0b7bd4097df7eefd7ce9dbe35cc9b584b0e4f5238dfd7c701cdbda2fb9f2279ab
6
+ metadata.gz: a18568aadaa039d7b14dfaecd8a95a2e909399c7640127e4389f9a9fc0875e30e9349a64747f2e2005c48e9281af44f42601ea6a22ea04b77f47ec77cdc2191b
7
+ data.tar.gz: 2a6e52c506b1c997e7ac881cad9117559471ed8af64c5bb7c1c503b98548b56d90610670f92f67d717c6393f9e370c360bebb15bcdd95e8d77ae08c5518ac469
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- ## 0.6.0.jhemphill2 07/11/2022
5
- * Fixed query tagging for empty queries
4
+ ## 0.6.0 07/11/2022
5
+ * Improved pper address tag to reflect the current database when using the mysql adapter
6
6
 
7
7
  ## 0.5.2 01/24/2022
8
8
  * Fixed query tagging for empty queries
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-instrumentation (0.6.0.jhemphill2)
4
+ activerecord-instrumentation (0.6.0)
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.6)
12
- activesupport (= 6.1.6)
13
- activerecord (6.1.6)
14
- activemodel (= 6.1.6)
15
- activesupport (= 6.1.6)
16
- activesupport (6.1.6)
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)
@@ -73,14 +73,15 @@ 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
- "connection" => payload[:connection].inspect,
83
- "peer.address" => peer_address_tag(payload.fetch(:connection, false))
84
+ "peer.address" => peer_address_tag(db_config)
84
85
  }.merge(db_statement(payload))
85
86
  end
86
87
 
@@ -105,32 +106,36 @@ module ActiveRecord
105
106
  sanitizer ? sanitizer.sanitize(sql) : sql
106
107
  end
107
108
 
108
- def peer_address_tag(connection)
109
- unless defined? @peer_address_tag
110
- if connection.respond_to? :host # using the postgres/mysql adapter
111
- @peer_address_tag = connection.host + "_hotdogs_"
112
- else
113
- @peer_address_tag = "farts"
114
- # [
115
- # "#{connection_config.fetch(:adapter)}://",
116
- # connection_config[:username],
117
- # connection_config[:host] && "@#{connection_config[:host]}",
118
- # "/#{db_instance}"
119
- # ].join
120
- end
121
- end
122
-
123
- @peer_address_tag
109
+ def peer_address_tag(config)
110
+ @peer_address_tag ||= [
111
+ "#{config.fetch(:adapter)}://",
112
+ config[:username],
113
+ config[:host] && "@#{config[:host]}",
114
+ "/#{db_instance}"
115
+ ].join
124
116
  end
125
117
 
126
118
  def db_instance
127
119
  @db_instance ||= connection_config.fetch(:database)
128
120
  end
129
121
 
130
- def connection_config
131
- # Rails 6.2 will deprecate ActiveRecord::Base.connection_config
132
- @connection_config ||=
133
- ActiveRecord::Base.try(:connection_db_config)&.configuration_hash || ActiveRecord::Base.connection_config
122
+ # If a connection is passed in, pull the db config options hash from it. This connection
123
+ # is likely to be attached to the query/query client. Fall back to the application level
124
+ # config. This change will show writer vs reader/replica dbs in spans when it is determined
125
+ # at the query level.
126
+ def connection_config(connection = nil)
127
+ unless defined? @connection_config
128
+ if connection.raw_connection && connection.raw_connection.respond_to?(:query_options)
129
+ # you have a mysql client
130
+ @connection_config = connection.raw_connection.query_options
131
+ else
132
+ # Rails 6.2 will deprecate ActiveRecord::Base.connection_config
133
+ @connection_config = ActiveRecord::Base.try(:connection_db_config)&.configuration_hash ||
134
+ ActiveRecord::Base.connection_config
135
+ end
136
+ end
137
+
138
+ @connection_config
134
139
  end
135
140
  end
136
141
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module OpenTracing
5
- VERSION = "0.6.0.jhemphill2"
5
+ VERSION = "0.6.0"
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.jhemphill2
4
+ version: 0.6.0
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 00:00:00.000000000 Z
12
+ date: 2022-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -209,9 +209,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">"
212
+ - - ">="
213
213
  - !ruby/object:Gem::Version
214
- version: 1.3.1
214
+ version: '0'
215
215
  requirements: []
216
216
  rubygems_version: 3.3.11
217
217
  signing_key: