opentelemetry-instrumentation-mysql2 0.13.0 → 0.18.0
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 +4 -4
- data/CHANGELOG.md +31 -8
- data/README.md +65 -0
- data/lib/opentelemetry/instrumentation/mysql2.rb +1 -0
- data/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb +3 -0
- data/lib/opentelemetry/instrumentation/mysql2/patches/client.rb +47 -3
- data/lib/opentelemetry/instrumentation/mysql2/version.rb +1 -1
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e1097f36ce3b194cdf0df01e5669c9a6db74f6d5556adc9f29900cabab1d62
|
4
|
+
data.tar.gz: a73c48dd8d12739d91a5dd28ad8cf86ff217d31fc1641b30fabd99ef8ba47628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e4c2378b2e6b8bcd77e6904911107a0df57e1782041c4cfdc98e3351f7e11086e069aeaeaf327dc608ea388e4639d0a8c4bee449909f9ff30733d56e27487a
|
7
|
+
data.tar.gz: 9ba36566d8841a8fff30bcf09a23fe6aedc3dc43e19ca8967980b3699bece98ac2341c37cfbfa03632e3c65f7c9a8890c81bd6788cd277928fd467331ec7c108
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-mysql2
|
2
2
|
|
3
|
+
### v0.18.0 / 2021-05-21
|
4
|
+
|
5
|
+
* ADDED: Updated API depedency for 1.0.0.rc1
|
6
|
+
* Fix: Nil value for db.name attribute #744
|
7
|
+
|
8
|
+
### v0.17.0 / 2021-04-22
|
9
|
+
|
10
|
+
* (No significant changes)
|
11
|
+
|
12
|
+
### v0.16.0 / 2021-03-17
|
13
|
+
|
14
|
+
* FIXED: Update DB semantic conventions
|
15
|
+
* FIXED: Example scripts now reference local common lib
|
16
|
+
* ADDED: Configurable obfuscation of sql in mysql2 instrumentation to avoid logging sensitive data
|
17
|
+
|
18
|
+
### v0.15.0 / 2021-02-18
|
19
|
+
|
20
|
+
* ADDED: Add instrumentation config validation
|
21
|
+
|
22
|
+
### v0.14.0 / 2021-02-03
|
23
|
+
|
24
|
+
* (No significant changes)
|
25
|
+
|
3
26
|
### v0.13.0 / 2021-01-29
|
4
27
|
|
5
28
|
* (No significant changes)
|
@@ -10,12 +33,12 @@
|
|
10
33
|
|
11
34
|
### v0.11.0 / 2020-12-11
|
12
35
|
|
13
|
-
* ADDED: Add peer service config to mysql
|
14
|
-
* FIXED: Copyright comments to not reference year
|
36
|
+
* ADDED: Add peer service config to mysql
|
37
|
+
* FIXED: Copyright comments to not reference year
|
15
38
|
|
16
39
|
### v0.10.1 / 2020-12-09
|
17
40
|
|
18
|
-
* FIXED: Semantic conventions db.type -> db.system
|
41
|
+
* FIXED: Semantic conventions db.type -> db.system
|
19
42
|
|
20
43
|
### v0.10.0 / 2020-12-03
|
21
44
|
|
@@ -23,19 +46,19 @@
|
|
23
46
|
|
24
47
|
### v0.9.0 / 2020-11-27
|
25
48
|
|
26
|
-
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
49
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
27
50
|
|
28
|
-
* ADDED: Add timeout for force_flush and shutdown
|
51
|
+
* ADDED: Add timeout for force_flush and shutdown
|
29
52
|
|
30
53
|
### v0.8.0 / 2020-10-27
|
31
54
|
|
32
|
-
* BREAKING CHANGE: Remove 'canonical' from status codes
|
55
|
+
* BREAKING CHANGE: Remove 'canonical' from status codes
|
33
56
|
|
34
|
-
* FIXED: Remove 'canonical' from status codes
|
57
|
+
* FIXED: Remove 'canonical' from status codes
|
35
58
|
|
36
59
|
### v0.7.0 / 2020-10-07
|
37
60
|
|
38
|
-
* DOCS: Standardize toplevel docs structure and readme
|
61
|
+
* DOCS: Standardize toplevel docs structure and readme
|
39
62
|
|
40
63
|
### v0.6.0 / 2020-09-10
|
41
64
|
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# OpenTelemetry Mysql2 Instrumentation
|
2
|
+
|
3
|
+
The OpenTelemetry Mysql2 Ruby gem is a community maintained instrumentation for [Mysql2][mysql2-home].
|
4
|
+
|
5
|
+
## How do I get started?
|
6
|
+
|
7
|
+
Install the gem using:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install opentelemetry-instrumentation-mysql2
|
11
|
+
```
|
12
|
+
|
13
|
+
Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-mysql2` in your `Gemfile`.
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
To use the instrumentation, call `use` with the name of the instrumentation:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
OpenTelemetry::SDK.configure do |c|
|
21
|
+
c.use 'OpenTelemetry::Instrumentation::Mysql2'
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
Alternatively, you can also call `use_all` to install all the available instrumentation.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
OpenTelemetry::SDK.configure do |c|
|
29
|
+
c.use_all
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
### Configuration options
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
OpenTelemetry::SDK.configure do |c|
|
37
|
+
c.use 'OpenTelemetry::Instrumentation::Mysql2', {
|
38
|
+
# The obfuscation of SQL in the db.statement attribute is disabled by default.
|
39
|
+
# To enable, set enable_sql_obfuscation to true.
|
40
|
+
enable_sql_obfuscation: false,
|
41
|
+
}
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
## Examples
|
46
|
+
|
47
|
+
An example of usage can be seen in [`example/mysql2.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/mysql2/example/mysql2.rb).
|
48
|
+
|
49
|
+
## How can I get involved?
|
50
|
+
|
51
|
+
The `opentelemetry-instrumentation-mysql2` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
52
|
+
|
53
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The `opentelemetry-instrumentation-mysql2` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
|
58
|
+
|
59
|
+
[mysql2-home]: https://github.com/brianmario/mysql2
|
60
|
+
[bundler-home]: https://bundler.io
|
61
|
+
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
62
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
63
|
+
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
64
|
+
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
65
|
+
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
@@ -30,11 +30,31 @@ module OpenTelemetry
|
|
30
30
|
|
31
31
|
QUERY_NAME_RE = Regexp.new("^(#{QUERY_NAMES.join('|')})", Regexp::IGNORECASE)
|
32
32
|
|
33
|
+
COMPONENTS_REGEX_MAP = {
|
34
|
+
single_quotes: /'(?:[^']|'')*?(?:\\'.*|'(?!'))/,
|
35
|
+
double_quotes: /"(?:[^"]|"")*?(?:\\".*|"(?!"))/,
|
36
|
+
numeric_literals: /-?\b(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?\b/,
|
37
|
+
boolean_literals: /\b(?:true|false|null)\b/i,
|
38
|
+
hexadecimal_literals: /0x[0-9a-fA-F]+/,
|
39
|
+
comments: /(?:#|--).*?(?=\r|\n|$)/i,
|
40
|
+
multi_line_comments: %r{\/\*(?:[^\/]|\/[^*])*?(?:\*\/|\/\*.*)}
|
41
|
+
}.freeze
|
42
|
+
|
43
|
+
MYSQL_COMPONENTS = %i[
|
44
|
+
single_quotes
|
45
|
+
double_quotes
|
46
|
+
numeric_literals
|
47
|
+
boolean_literals
|
48
|
+
hexadecimal_literals
|
49
|
+
comments
|
50
|
+
multi_line_comments
|
51
|
+
].freeze
|
52
|
+
|
33
53
|
def query(sql, options = {})
|
34
54
|
tracer.in_span(
|
35
55
|
database_span_name(sql),
|
36
56
|
attributes: client_attributes.merge(
|
37
|
-
'db.statement' => sql
|
57
|
+
'db.statement' => obfuscate_sql(sql)
|
38
58
|
),
|
39
59
|
kind: :client
|
40
60
|
) do
|
@@ -44,6 +64,31 @@ module OpenTelemetry
|
|
44
64
|
|
45
65
|
private
|
46
66
|
|
67
|
+
def obfuscate_sql(sql)
|
68
|
+
return sql unless config[:enable_sql_obfuscation]
|
69
|
+
|
70
|
+
if sql.size > 2000
|
71
|
+
'SQL query too large to remove sensitive data ...'
|
72
|
+
else
|
73
|
+
obfuscated = sql.gsub(generated_mysql_regex, '?')
|
74
|
+
obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated)
|
75
|
+
obfuscated
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def generated_mysql_regex
|
80
|
+
@generated_mysql_regex ||= Regexp.union(MYSQL_COMPONENTS.map { |component| COMPONENTS_REGEX_MAP[component] })
|
81
|
+
end
|
82
|
+
|
83
|
+
def detect_unmatched_pairs(obfuscated)
|
84
|
+
# We use this to check whether the query contains any quote characters
|
85
|
+
# after obfuscation. If so, that's a good indication that the original
|
86
|
+
# query was malformed, and so our obfuscation can't reliably find
|
87
|
+
# literals. In such a case, we'll replace the entire query with a
|
88
|
+
# placeholder.
|
89
|
+
%r{'|"|\/\*|\*\/}.match(obfuscated)
|
90
|
+
end
|
91
|
+
|
47
92
|
def database_span_name(sql)
|
48
93
|
# Setting span name to the SQL query without obfuscation would
|
49
94
|
# result in PII + cardinality issues.
|
@@ -74,11 +119,10 @@ module OpenTelemetry
|
|
74
119
|
|
75
120
|
attributes = {
|
76
121
|
'db.system' => 'mysql',
|
77
|
-
'db.instance' => database_name,
|
78
|
-
'db.url' => "mysql://#{host}:#{port}",
|
79
122
|
'net.peer.name' => host,
|
80
123
|
'net.peer.port' => port
|
81
124
|
}
|
125
|
+
attributes['db.name'] = database_name if database_name
|
82
126
|
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
83
127
|
attributes
|
84
128
|
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.
|
4
|
+
version: 0.18.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-
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 1.0.0.rc1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-instrumentation-base
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.18.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.18.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: appraisal
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 1.0.0.rc1
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 1.0.0.rc1
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rubocop
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +174,7 @@ files:
|
|
160
174
|
- ".yardopts"
|
161
175
|
- CHANGELOG.md
|
162
176
|
- LICENSE
|
177
|
+
- README.md
|
163
178
|
- lib/opentelemetry-instrumentation-mysql2.rb
|
164
179
|
- lib/opentelemetry/instrumentation.rb
|
165
180
|
- lib/opentelemetry/instrumentation/mysql2.rb
|
@@ -170,10 +185,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
170
185
|
licenses:
|
171
186
|
- Apache-2.0
|
172
187
|
metadata:
|
173
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.
|
188
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.18.0/file.CHANGELOG.html
|
174
189
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mysql2
|
175
190
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
176
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.
|
191
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.18.0
|
177
192
|
post_install_message:
|
178
193
|
rdoc_options: []
|
179
194
|
require_paths:
|
@@ -189,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
204
|
- !ruby/object:Gem::Version
|
190
205
|
version: '0'
|
191
206
|
requirements: []
|
192
|
-
rubygems_version: 3.1.
|
207
|
+
rubygems_version: 3.1.6
|
193
208
|
signing_key:
|
194
209
|
specification_version: 4
|
195
210
|
summary: Mysql2 instrumentation for the OpenTelemetry framework
|