activerecord-instrumentation 0.6.0.jhemphill3 → 0.6.1.pre

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: 95c186a845e1f54640ec23d41c6f4af63672c70a2b40eead66abd7dfdfa9a5d9
4
- data.tar.gz: 5dbd6b7b69424ff53fe2aaaecd2c9980ea427f32ac85b69f779b6bd60fbfe1c5
3
+ metadata.gz: e0c5d0d44e18ee992c3f8458ab3e4a8f6fe3738ce47cbb553224aec647901113
4
+ data.tar.gz: 73152d2108ae460ee4c4795b1e3b50e4af567cc8292469b0c02ee7b7f251046b
5
5
  SHA512:
6
- metadata.gz: 1542c660df6a46953df85ed993648afcf28b3a5195560176b528d7f03dd148ad404bbe53e732ea8ac4a0fa6f81cc471e89bb8931da42aa0c181ac93c819f8b36
7
- data.tar.gz: bf4172f41056e08ef86bbcab7a6c56cd2d044d90f18ccd600ac59758ead73abf056283e7b2424771460b6a1ed6fd9a74d0d36ac790986629810d429167d259b6
6
+ metadata.gz: 51ba7e18ebd147dd0ea8f80c50f675f8655f29bb77b360b95f1d1b94685c7c9d00f00a1ca5083055e21d48a520a73e8ff6d1228ac19dfc9032c9ac995911bd2e
7
+ data.tar.gz: c108734ef121ad092f5fe24b7a477a287c6cabc57ca956f407547eddf77e13d5663d1174c8f77960cfb28889d2f1bd9c390900531edd19f51c1c85f070487e56
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- ## 0.6.0.jhemphill3 07/11/2022
5
- * Fixed query tagging for empty queries
4
+ ## 0.6.1.pre 09/07/2022
5
+ * Splat hash when passing method expecting keyword args
6
+
7
+ ## 0.6.0 07/11/2022
8
+ * Improved pper address tag to reflect the current database when using the mysql adapter
6
9
 
7
10
  ## 0.5.2 01/24/2022
8
11
  * Fixed query tagging for empty queries
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-instrumentation (0.6.0.jhemphill3)
4
+ activerecord-instrumentation (0.6.1.pre)
5
5
  activerecord
6
6
  opentracing (~> 0.5)
7
7
 
@@ -54,7 +54,7 @@ module ActiveRecord
54
54
 
55
55
  if (exception = payload[:exception_object])
56
56
  span.set_tag("error", true)
57
- span.log_kv(exception_metadata(exception))
57
+ span.log_kv(**exception_metadata(exception))
58
58
  end
59
59
 
60
60
  span.finish(end_time: finish)
@@ -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
- "peer.mysql_db_name" => mysql_db_name_tag(payload.fetch(:connection, nil)&.raw_connection),
83
- "peer.address" => peer_address_tag
84
+ "peer.address" => peer_address_tag(db_config)
84
85
  }.merge(db_statement(payload))
85
86
  end
86
87
 
@@ -105,29 +106,36 @@ module ActiveRecord
105
106
  sanitizer ? sanitizer.sanitize(sql) : sql
106
107
  end
107
108
 
108
- def mysql_db_name_tag(db_connection)
109
- return db_connection.host if db_connection.respond_to?(:host)
110
- return nil
111
- end
112
-
113
- def peer_address_tag
114
- @peer_address_tag ||=
115
- [
116
- "#{connection_config.fetch(:adapter)}://",
117
- connection_config[:username],
118
- connection_config[:host] && "@#{connection_config[:host]}",
119
- "/#{db_instance}"
120
- ].join
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
121
116
  end
122
117
 
123
118
  def db_instance
124
119
  @db_instance ||= connection_config.fetch(:database)
125
120
  end
126
121
 
127
- def connection_config
128
- # Rails 6.2 will deprecate ActiveRecord::Base.connection_config
129
- @connection_config ||=
130
- 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
131
139
  end
132
140
  end
133
141
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module OpenTracing
5
- VERSION = "0.6.0.jhemphill3"
5
+ VERSION = "0.6.1.pre"
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.jhemphill3
4
+ version: 0.6.1.pre
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-09-07 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.3.11
216
+ rubygems_version: 3.1.6
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: ActiveRecord OpenTracing intrumenter