opentelemetry-instrumentation-mysql2 0.21.1 → 0.23.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: 72d506d7b5ea829dc35ee0f90a02a0ed2231b895204016a806e45a9561f4bce1
4
- data.tar.gz: 41d0788f8de74f287a736cf4e70fa106d6963391bb5561a82bd48bb2432e1041
3
+ metadata.gz: 9ea7871c2d5272a19f91159b2b9f72e07e265fed7dd673c03b3ef2c7506aed62
4
+ data.tar.gz: 49579a5b7030b8fd8e19900158ad8438ed91a2f9188e8d1e4ee2799503f72f4a
5
5
  SHA512:
6
- metadata.gz: 13c5fad74e52b3865b6d9366820be142ac778326cd8e6156ad9899b8f3ba92964797bc727fb2504f654ed4cb37c38472496958dfd4647d1b0ef6be55a8834c63
7
- data.tar.gz: 13837ce27d7519f1671a74539faa7b9fa13faea8a36bb96b48af806f9b9c8d6f7ce03b7dbb00fb4ab3d4dee120e655457176f1ba001dbba57e8aaa3f7f96c209
6
+ metadata.gz: d762f5106fd527d7f4dfc43830bb6ad7fc46cb7944e8b2468888fe77078c39a3764836149124760c04a8738c9840ec028f34f54899ab5a33dba99b66cadb02d5
7
+ data.tar.gz: 3e55e547de48c4b2132d4a95023627a8d1a96b0a5f7ee38c3bc565548b541c8da8f2f64817cc636b7de830642a931899b47860939e290d3cbcda7e26b244bc06
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Release History: opentelemetry-instrumentation-mysql2
2
2
 
3
+ ### v0.23.0 / 2023-04-17
4
+
5
+ * BREAKING CHANGE: Drop support for EoL Ruby 2.7
6
+
7
+ * ADDED: Drop support for EoL Ruby 2.7
8
+ * FIXED: Ensure encoding errors handled during SQL obfuscation for Trilogy
9
+
10
+ ### v0.22.0 / 2023-01-14
11
+
12
+ * BREAKING CHANGE: Removed deprecated instrumentation options
13
+
14
+ * ADDED: Add option to configure span name
15
+ * ADDED: Removed deprecated instrumentation options
16
+ * DOCS: Fix gem homepage
17
+ * DOCS: More gem documentation fixes
18
+
3
19
  ### v0.21.1 / 2022-10-26
4
20
 
5
21
  * FIXED: Handle encoding errors in mysql obfuscation
@@ -10,15 +10,7 @@ module OpenTelemetry
10
10
  # The Instrumentation class contains logic to detect and install the Mysql2
11
11
  # instrumentation
12
12
  class Instrumentation < OpenTelemetry::Instrumentation::Base
13
- install do |config|
14
- if config[:enable_sql_obfuscation]
15
- config[:db_statement] = :obfuscate
16
- OpenTelemetry.logger.warn(
17
- 'Instrumentation mysql2 configuration option enable_sql_obfuscation has been deprecated,' \
18
- 'use db_statement option instead'
19
- )
20
- end
21
-
13
+ install do |_config|
22
14
  require_dependencies
23
15
  patch_client
24
16
  end
@@ -28,8 +20,8 @@ module OpenTelemetry
28
20
  end
29
21
 
30
22
  option :peer_service, default: nil, validate: :string
31
- option :enable_sql_obfuscation, default: false, validate: :boolean
32
23
  option :db_statement, default: :include, validate: %I[omit include obfuscate]
24
+ option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name]
33
25
 
34
26
  private
35
27
 
@@ -54,9 +54,9 @@ module OpenTelemetry
54
54
  attributes = client_attributes
55
55
  case config[:db_statement]
56
56
  when :include
57
- attributes['db.statement'] = sql
57
+ attributes[SemanticConventions::Trace::DB_STATEMENT] = sql
58
58
  when :obfuscate
59
- attributes['db.statement'] = obfuscate_sql(sql)
59
+ attributes[SemanticConventions::Trace::DB_STATEMENT] = obfuscate_sql(sql)
60
60
  end
61
61
  tracer.in_span(
62
62
  database_span_name(sql),
@@ -78,7 +78,8 @@ module OpenTelemetry
78
78
  obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated)
79
79
  obfuscated
80
80
  end
81
- rescue StandardError
81
+ rescue StandardError => e
82
+ OpenTelemetry.handle_error(message: 'Failed to obfuscate SQL', exception: e)
82
83
  'OpenTelemetry error: failed to obfuscate sql'
83
84
  end
84
85
 
@@ -95,20 +96,23 @@ module OpenTelemetry
95
96
  %r{'|"|\/\*|\*\/}.match(obfuscated)
96
97
  end
97
98
 
98
- def database_span_name(sql)
99
- # Setting span name to the SQL query without obfuscation would
100
- # result in PII + cardinality issues.
101
- # First attempt to infer the statement type then fallback to
102
- # current Otel approach {database.component_name}.{database_instance_name}
103
- # https://github.com/open-telemetry/opentelemetry-python/blob/39fa078312e6f41c403aa8cad1868264011f7546/ext/opentelemetry-ext-dbapi/tests/test_dbapi_integration.py#L53
104
- # This creates span names like mysql.default, mysql.replica, postgresql.staging etc.
105
-
106
- statement_type = extract_statement_type(sql)
107
-
108
- return statement_type unless statement_type.nil?
109
-
110
- # fallback
111
- database_name ? "mysql.#{database_name}" : 'mysql'
99
+ def database_span_name(sql) # rubocop:disable Metrics/CyclomaticComplexity
100
+ case config[:span_name]
101
+ when :statement_type
102
+ extract_statement_type(sql)
103
+ when :db_name
104
+ database_name
105
+ when :db_operation_and_name
106
+ op = OpenTelemetry::Instrumentation::Mysql2.attributes[SemanticConventions::Trace::DB_OPERATION]
107
+ name = database_name
108
+ if op && name
109
+ "#{op} #{name}"
110
+ elsif op
111
+ op
112
+ elsif name
113
+ name
114
+ end
115
+ end || 'mysql'
112
116
  end
113
117
 
114
118
  def database_name
@@ -124,12 +128,12 @@ module OpenTelemetry
124
128
  port = query_options[:port].to_s
125
129
 
126
130
  attributes = {
127
- 'db.system' => 'mysql',
128
- 'net.peer.name' => host,
129
- 'net.peer.port' => port
131
+ SemanticConventions::Trace::DB_SYSTEM => 'mysql',
132
+ SemanticConventions::Trace::NET_PEER_NAME => host,
133
+ SemanticConventions::Trace::NET_PEER_PORT => port
130
134
  }
131
- attributes['db.name'] = database_name if database_name
132
- attributes['peer.service'] = config[:peer_service] if config[:peer_service]
135
+ attributes[SemanticConventions::Trace::DB_NAME] = database_name if database_name
136
+ attributes[SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
133
137
  attributes
134
138
  end
135
139
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Mysql2
10
- VERSION = '0.21.1'
10
+ VERSION = '0.23.0'
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.21.1
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.21.0
33
+ version: 0.22.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.21.0
40
+ version: 0.22.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.17'
61
+ version: '2.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.17'
68
+ version: '2.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: opentelemetry-test-helpers
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '0.3'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '0.3'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.3.0
159
+ version: 1.48.1
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.3.0
166
+ version: 1.48.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: simplecov
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -223,14 +223,14 @@ files:
223
223
  - lib/opentelemetry/instrumentation/mysql2/instrumentation.rb
224
224
  - lib/opentelemetry/instrumentation/mysql2/patches/client.rb
225
225
  - lib/opentelemetry/instrumentation/mysql2/version.rb
226
- homepage: https://github.com/open-telemetry/opentelemetry-contrib
226
+ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
227
227
  licenses:
228
228
  - Apache-2.0
229
229
  metadata:
230
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-mysql2/v0.21.1/file.CHANGELOG.html
230
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.23.0/file/CHANGELOG.md
231
231
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/mysql2
232
232
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
233
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-mysql2/v0.21.1
233
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-mysql2/0.23.0
234
234
  post_install_message:
235
235
  rdoc_options: []
236
236
  require_paths:
@@ -239,14 +239,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
- version: 2.6.0
242
+ version: '3.0'
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  requirements:
245
245
  - - ">="
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  requirements: []
249
- rubygems_version: 3.1.6
249
+ rubygems_version: 3.2.33
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: Mysql2 instrumentation for the OpenTelemetry framework