opentelemetry-instrumentation-mysql2 0.26.1 → 0.27.1

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: 8bb52d41370dd6f755503f63f131a747bb9790f7fb680f863dc4864932c7b5c1
4
- data.tar.gz: f1779dde36425c213453c779d3ffe3cf3cd4f2bc71f2e6f83cce3c143567e505
3
+ metadata.gz: 7a68fd97fe9d02dc68d6451315ec27980fc9db7484778e646631897be3da2d5c
4
+ data.tar.gz: 8419c5fd4fe63fc5c709cf39a52aa7d3584d162d64780e5bada5a71e8df1e63a
5
5
  SHA512:
6
- metadata.gz: 6c880aabf7e508fec4e11b83663319dfb620c890da0e1860d567e548427ad11bdef3811ccdc72d42cca0a056388a1ed87c0620057447492299ca6654c6d8731b
7
- data.tar.gz: ab203d87c0d2d12afa8ba9596ae01ceba00c33802079d87a02f067d22b935795b9516764ff17bf58829ea42c6a0f0eaf54adf2a64ed535051ed9fe88b86903a8
6
+ metadata.gz: 429d4ba8a52467a5b9a88b9cb9ebb5919349fb8822ac82837ad6084a2d77cca1dfd066c76470223f86d2059bf72feeecc3261c1649c43c66cc674e7b8547bd44
7
+ data.tar.gz: e2fa0302ae098d0f7e4fb6089f4362d1765aa5bfc71ccc5c519124c0b147c9eff0ae3b75b1b7a4dd485a1037992f3b13db4cddb5d55644d6c650ce356ce61a2b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release History: opentelemetry-instrumentation-mysql2
2
2
 
3
+ ### v0.27.1 / 2024-04-30
4
+
5
+ * FIXED: Bundler conflict warnings
6
+
7
+ ### v0.27.0 / 2024-02-15
8
+
9
+ * ADDED: Instrument mysql2 prepare statement
10
+
3
11
  ### v0.26.1 / 2024-02-08
4
12
 
5
13
  * FIXED: Add missing requires for sql-helpers to mysql, pg, and trilogy instrumentation
@@ -14,7 +14,40 @@ module OpenTelemetry
14
14
  # Module to prepend to Mysql2::Client for instrumentation
15
15
  module Client
16
16
  def query(sql, options = {})
17
- attributes = client_attributes
17
+ tracer.in_span(
18
+ _otel_span_name(sql),
19
+ attributes: _otel_span_attributes(sql),
20
+ kind: :client
21
+ ) do
22
+ super(sql, options)
23
+ end
24
+ end
25
+
26
+ def prepare(sql)
27
+ tracer.in_span(
28
+ _otel_span_name(sql),
29
+ attributes: _otel_span_attributes(sql),
30
+ kind: :client
31
+ ) do
32
+ super(sql)
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def _otel_span_name(sql)
39
+ OpenTelemetry::Helpers::MySQL.database_span_name(
40
+ sql,
41
+ OpenTelemetry::Instrumentation::Mysql2.attributes[
42
+ SemanticConventions::Trace::DB_OPERATION
43
+ ],
44
+ _otel_database_name,
45
+ config
46
+ )
47
+ end
48
+
49
+ def _otel_span_attributes(sql)
50
+ attributes = _otel_client_attributes
18
51
  case config[:db_statement]
19
52
  when :include
20
53
  attributes[SemanticConventions::Trace::DB_STATEMENT] = sql
@@ -24,30 +57,18 @@ module OpenTelemetry
24
57
  sql, obfuscation_limit: config[:obfuscation_limit], adapter: :mysql
25
58
  )
26
59
  end
27
- tracer.in_span(
28
- OpenTelemetry::Helpers::MySQL.database_span_name(
29
- sql,
30
- OpenTelemetry::Instrumentation::Mysql2.attributes[
31
- SemanticConventions::Trace::DB_OPERATION
32
- ],
33
- database_name,
34
- config
35
- ),
36
- attributes: attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes),
37
- kind: :client
38
- ) do
39
- super(sql, options)
40
- end
41
- end
42
60
 
43
- private
61
+ attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes)
62
+ attributes.compact!
63
+ attributes
64
+ end
44
65
 
45
- def database_name
66
+ def _otel_database_name
46
67
  # https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L78
47
68
  (query_options[:database] || query_options[:dbname] || query_options[:db])&.to_s
48
69
  end
49
70
 
50
- def client_attributes
71
+ def _otel_client_attributes
51
72
  # The client specific attributes can be found via the query_options instance variable
52
73
  # exposed on the mysql2 Client
53
74
  # https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L25-L26
@@ -59,8 +80,9 @@ module OpenTelemetry
59
80
  SemanticConventions::Trace::NET_PEER_NAME => host,
60
81
  SemanticConventions::Trace::NET_PEER_PORT => port
61
82
  }
62
- attributes[SemanticConventions::Trace::DB_NAME] = database_name if database_name
63
- attributes[SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
83
+
84
+ attributes[SemanticConventions::Trace::DB_NAME] = _otel_database_name
85
+ attributes[SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service]
64
86
  attributes
65
87
  end
66
88
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Mysql2
10
- VERSION = '0.26.1'
10
+ VERSION = '0.27.1'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '5.0'
111
- - !ruby/object:Gem::Dependency
112
- name: mysql2
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 0.4.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 0.4.0
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: opentelemetry-sdk
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +170,14 @@ dependencies:
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: 1.60.1
173
+ version: '1.62'
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: 1.60.1
180
+ version: '1.62'
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: rubocop-performance
197
183
  requirement: !ruby/object:Gem::Requirement
@@ -255,10 +241,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
255
241
  licenses:
256
242
  - Apache-2.0
257
243
  metadata:
258
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.26.1/file/CHANGELOG.md
244
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.27.1/file/CHANGELOG.md
259
245
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/mysql2
260
246
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
261
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.26.1
247
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.27.1
262
248
  post_install_message:
263
249
  rdoc_options: []
264
250
  require_paths: