opentelemetry-instrumentation-mysql2 0.19.1 → 0.21.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: 12b6b5712065c1bd63b04766999270aed5e6feb68f30becc97f453d23ccfffb9
4
- data.tar.gz: dc7d19ddd48df92d5463df04b265dfcc8a98366a2ef62199e032a68c6d4193f2
3
+ metadata.gz: 4289cd2222f7e02809e775d1ebe4201fb87abbdd3eca443230c6b3d82ff338d2
4
+ data.tar.gz: 67e7e40dac313faac5fc2be2ed7638868c729516b869e5721c26ce16ddaba2fc
5
5
  SHA512:
6
- metadata.gz: 1f5ed045c7a312ee4487b064ca810fedff9cac72e86d7b7b851db5d411df19a61feb6bd71cf83b5c7b081eb9ac2edfecfd544d7c62324a741a3c113959ba7a36
7
- data.tar.gz: 37944cd8d1e6b40a0c95e8c40b2b6dfbb20a2a36ef956a2b8c710a346b4c1bfa87431be9b07d167472365b641899c6995ca29be692696b35b1034a8116b66217
6
+ metadata.gz: 4c8768bcc3400a86832cdce83a82e390ec9cbe4f614a76621a108e5f28971e824781c4e08848177c3af9cae4bd662539c4845767aaf27fcb6a484ebb513fe45b
7
+ data.tar.gz: 141513bd59aec67545022a4369d0e437760687d36c36ccfb0795c7e00595810beba59c1af45cfa3ec81af4faa03bc7f9d1214d7871d194ff7e9e234cd00cee8b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Release History: opentelemetry-instrumentation-mysql2
2
2
 
3
+ ### v0.21.0 / 2022-06-09
4
+
5
+ * Upgrading Base dependency version
6
+ * FIXED: Broken test file requirements
7
+
8
+ ### v0.20.1 / 2022-05-03
9
+
10
+ * ADDED: `with_attributes` method for context propagation
11
+
12
+ ### v0.20.0 / 2021-12-01
13
+
14
+ * ADDED: Add default options config helper + env var config option support
15
+
3
16
  ### v0.19.1 / 2021-09-29
4
17
 
5
18
  * (No significant changes)
data/README.md CHANGED
@@ -30,6 +30,17 @@ OpenTelemetry::SDK.configure do |c|
30
30
  end
31
31
  ```
32
32
 
33
+ The `mysql2` instrumentation allows the user to supply additional attributes via the `with_attributes` method. This makes it possible to supply additional attributes on mysql2 spans. Attributes supplied in `with_attributes` supersede those automatically generated within `mysql2`'s automatic instrumentation. If you supply a `db.statement` attribute in `with_attributes`, this library's `:db_statement` configuration will not be applied.
34
+
35
+ ```ruby
36
+ require 'opentelemetry/instrumentation/mysql2'
37
+
38
+ client = Mysql2::Client.new(:host => "localhost", :username => "root")
39
+ OpenTelemetry::Instrumentation::Mysql2.with_attributes('pizzatoppings' => 'mushrooms') do
40
+ client.query("SELECT 1")
41
+ end
42
+ ```
43
+
33
44
  ### Configuration options
34
45
 
35
46
  ```ruby
@@ -29,7 +29,7 @@ module OpenTelemetry
29
29
 
30
30
  option :peer_service, default: nil, validate: :string
31
31
  option :enable_sql_obfuscation, default: false, validate: :boolean
32
- option :db_statement, default: :include, validate: ->(opt) { %I[omit include obfuscate].include?(opt) }
32
+ option :db_statement, default: :include, validate: %I[omit include obfuscate]
33
33
 
34
34
  private
35
35
 
@@ -60,7 +60,7 @@ module OpenTelemetry
60
60
  end
61
61
  tracer.in_span(
62
62
  database_span_name(sql),
63
- attributes: attributes,
63
+ attributes: attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes),
64
64
  kind: :client
65
65
  ) do
66
66
  super(sql, options)
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Mysql2
10
- VERSION = '0.19.1'
10
+ VERSION = '0.21.0'
11
11
  end
12
12
  end
13
13
  end
@@ -11,6 +11,45 @@ module OpenTelemetry
11
11
  module Instrumentation
12
12
  # Contains the OpenTelemetry instrumentation for the Mysql2 gem
13
13
  module Mysql2
14
+ extend self
15
+
16
+ CURRENT_ATTRIBUTES_KEY = Context.create_key('mysql-attributes-hash')
17
+
18
+ private_constant :CURRENT_ATTRIBUTES_KEY
19
+
20
+ # Returns the attributes hash representing the Mysql2 context found
21
+ # in the optional context or the current context if none is provided.
22
+ #
23
+ # @param [optional Context] context The context to lookup the current
24
+ # attributes hash. Defaults to Context.current
25
+ def attributes(context = nil)
26
+ context ||= Context.current
27
+ context.value(CURRENT_ATTRIBUTES_KEY) || {}
28
+ end
29
+
30
+ # Returns a context containing the merged attributes hash, derived from the
31
+ # optional parent context, or the current context if one was not provided.
32
+ #
33
+ # @param [optional Context] context The context to use as the parent for
34
+ # the returned context
35
+ def context_with_attributes(attributes_hash, parent_context: Context.current)
36
+ attributes_hash = attributes(parent_context).merge(attributes_hash)
37
+ parent_context.set_value(CURRENT_ATTRIBUTES_KEY, attributes_hash)
38
+ end
39
+
40
+ # Activates/deactivates the merged attributes hash within the current Context,
41
+ # which makes the "current attributes hash" available implicitly.
42
+ #
43
+ # On exit, the attributes hash that was active before calling this method
44
+ # will be reactivated.
45
+ #
46
+ # @param [Span] span the span to activate
47
+ # @yield [Hash, Context] yields attributes hash and a context containing the
48
+ # attributes hash to the block.
49
+ def with_attributes(attributes_hash)
50
+ attributes_hash = attributes.merge(attributes_hash)
51
+ Context.with_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) { |c, h| yield h, c }
52
+ end
14
53
  end
15
54
  end
16
55
  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.19.1
4
+ version: 0.21.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: 2021-09-30 00:00:00.000000000 Z
11
+ date: 2022-06-09 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.18.3
33
+ version: 0.21.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.18.3
40
+ version: 0.21.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
103
+ version: '1.1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.0'
110
+ version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: opentelemetry-test-helpers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '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'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -213,10 +227,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
213
227
  licenses:
214
228
  - Apache-2.0
215
229
  metadata:
216
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.19.1/file.CHANGELOG.html
230
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.21.0/file.CHANGELOG.html
217
231
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mysql2
218
232
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
219
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.19.1
233
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.21.0
220
234
  post_install_message:
221
235
  rdoc_options: []
222
236
  require_paths:
@@ -225,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
239
  requirements:
226
240
  - - ">="
227
241
  - !ruby/object:Gem::Version
228
- version: 2.5.0
242
+ version: 2.6.0
229
243
  required_rubygems_version: !ruby/object:Gem::Requirement
230
244
  requirements:
231
245
  - - ">="