opentelemetry-instrumentation-mysql2 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7192d94f430fbbbe5892958eb5fd21f247fb6637ed8b22ccb4f167f72bfa7e
|
4
|
+
data.tar.gz: d9c54284fcead9d2a8fc5c33ce97a47b5548108b1eab92750288d3af87712817
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af35833d59163dc130bb325d23347171a09af2e03d10b9d4b6012bc6284296bc942bfd07e01393ca39d9c905785d15b10cc198fdb136d030542e8f489a339cac
|
7
|
+
data.tar.gz: 17bfa240040ac4f21830031f5dff5a654177d771e37582afe3379581d965312d4447e7168b517384133bff33720b9403f5449c0eb9d1f47fe7506fe0ed345791
|
data/CHANGELOG.md
CHANGED
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
|
@@ -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.20.
|
4
|
+
version: 0.20.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:
|
11
|
+
date: 2022-05-05 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.
|
33
|
+
version: 0.20.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.
|
40
|
+
version: 0.20.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: appraisal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
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.20.
|
230
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.20.1/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.20.
|
233
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.20.1
|
220
234
|
post_install_message:
|
221
235
|
rdoc_options: []
|
222
236
|
require_paths:
|