opentelemetry-instrumentation-mysql2 0.11.0 → 0.16.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89fb1be56f26510a07111f785844a64bb8afa67b451967481f66b34fb4148918
|
4
|
+
data.tar.gz: 2fda38e2e737d5400de33644f634a2fd01b292de783af6c79a7f7ab202d5c2e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c606394f621ae305fe5eea6b9167bd5fc6303aa2c73365d6d381f0f2dbe545d91caa2ed3c55e6e7db62797381eaccdea0f68afeb38f2efb6673282fcae3f68ae
|
7
|
+
data.tar.gz: 430c6c8530deee4cfa85f739c256663ac536eec693a0e39a8899f7b73d2a6f3b896787802b349ed4dbb46758ce4552ad3ff0e3a3d4acaaa20f569e1724a9fad8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-mysql2
|
2
2
|
|
3
|
+
### v0.16.0 / 2021-03-17
|
4
|
+
|
5
|
+
* FIXED: Update DB semantic conventions
|
6
|
+
* FIXED: Example scripts now reference local common lib
|
7
|
+
* ADDED: Configurable obfuscation of sql in mysql2 instrumentation to avoid logging sensitive data
|
8
|
+
|
9
|
+
### v0.15.0 / 2021-02-18
|
10
|
+
|
11
|
+
* ADDED: Add instrumentation config validation
|
12
|
+
|
13
|
+
### v0.14.0 / 2021-02-03
|
14
|
+
|
15
|
+
* (No significant changes)
|
16
|
+
|
17
|
+
### v0.13.0 / 2021-01-29
|
18
|
+
|
19
|
+
* (No significant changes)
|
20
|
+
|
21
|
+
### v0.12.0 / 2020-12-24
|
22
|
+
|
23
|
+
* (No significant changes)
|
24
|
+
|
3
25
|
### v0.11.0 / 2020-12-11
|
4
26
|
|
5
27
|
* ADDED: Add peer service config to mysql
|
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,8 +119,7 @@ module OpenTelemetry
|
|
74
119
|
|
75
120
|
attributes = {
|
76
121
|
'db.system' => 'mysql',
|
77
|
-
'db.
|
78
|
-
'db.url' => "mysql://#{host}:#{port}",
|
122
|
+
'db.name' => database_name,
|
79
123
|
'net.peer.name' => host,
|
80
124
|
'net.peer.port' => port
|
81
125
|
}
|
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.16.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:
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.16.0
|
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: 0.16.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- ".yardopts"
|
161
161
|
- CHANGELOG.md
|
162
162
|
- LICENSE
|
163
|
+
- README.md
|
163
164
|
- lib/opentelemetry-instrumentation-mysql2.rb
|
164
165
|
- lib/opentelemetry/instrumentation.rb
|
165
166
|
- lib/opentelemetry/instrumentation/mysql2.rb
|
@@ -170,10 +171,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
170
171
|
licenses:
|
171
172
|
- Apache-2.0
|
172
173
|
metadata:
|
173
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.
|
174
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/
|
174
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.16.0/file.CHANGELOG.html
|
175
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mysql2
|
175
176
|
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.
|
177
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v0.16.0
|
177
178
|
post_install_message:
|
178
179
|
rdoc_options: []
|
179
180
|
require_paths:
|