opentelemetry-instrumentation-pg 0.26.0 → 0.27.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc1cf9d4064f6c7acdf160a45b360347c5ad87ffad97a63e086ccea564b396c
|
4
|
+
data.tar.gz: 5bf6eb9b540fd53b53d51126ebd8cce58cc640587f9a9ab7bc3aea9a20026a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f870b5c594e85710a9e71f514ae37059d679601d1d381f5854baf054f780b7504777b12a40e09decbd295852dc9c0b1bb951e97588e8d61b4dfd7e1f8b88f00
|
7
|
+
data.tar.gz: 62479ce766cf77cae8ea0854443d2a71882c9bc1995749c2f07bca70b4890cda2c91d18f1e45e0d27923652111a77257f5aa80e4caa88356f2574680e2647fce
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-pg
|
2
2
|
|
3
|
+
### v0.27.0 / 2024-02-08
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Move shared sql behavior to helper gems
|
6
|
+
|
7
|
+
|
8
|
+
### v0.26.1 / 2023-11-23
|
9
|
+
|
10
|
+
* CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
|
11
|
+
|
3
12
|
### v0.26.0 / 2023-10-16
|
4
13
|
|
5
14
|
* BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement
|
@@ -65,29 +65,6 @@ module OpenTelemetry
|
|
65
65
|
VALUES
|
66
66
|
].freeze
|
67
67
|
|
68
|
-
# From: https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscation_helpers.rb#L9-L34
|
69
|
-
COMPONENTS_REGEX_MAP = {
|
70
|
-
single_quotes: /'(?:[^']|'')*?(?:\\'.*|'(?!'))/,
|
71
|
-
dollar_quotes: /(\$(?!\d)[^$]*?\$).*?(?:\1|$)/,
|
72
|
-
uuids: /\{?(?:[0-9a-fA-F]\-*){32}\}?/,
|
73
|
-
numeric_literals: /-?\b(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?\b/,
|
74
|
-
boolean_literals: /\b(?:true|false|null)\b/i,
|
75
|
-
comments: /(?:#|--).*?(?=\r|\n|$)/i,
|
76
|
-
multi_line_comments: %r{\/\*(?:[^\/]|\/[^*])*?(?:\*\/|\/\*.*)}
|
77
|
-
}.freeze
|
78
|
-
|
79
|
-
POSTGRES_COMPONENTS = %i[
|
80
|
-
single_quotes
|
81
|
-
dollar_quotes
|
82
|
-
uuids
|
83
|
-
numeric_literals
|
84
|
-
boolean_literals
|
85
|
-
comments
|
86
|
-
multi_line_comments
|
87
|
-
].freeze
|
88
|
-
|
89
|
-
UNMATCHED_PAIRS_REGEX = %r{'|\/\*|\*\/|\$(?!\?)}
|
90
|
-
|
91
68
|
# These are all alike in that they will have a SQL statement as the first parameter.
|
92
69
|
# That statement may possibly be parameterized, but we can still use it - the
|
93
70
|
# obfuscation code will just transform $1 -> $? in that case (which is fine enough).
|
@@ -50,6 +50,16 @@ module OpenTelemetry
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
+
def obfuscate_sql(sql)
|
54
|
+
return sql unless config[:db_statement] == :obfuscate
|
55
|
+
|
56
|
+
OpenTelemetry::Helpers::SqlObfuscation.obfuscate_sql(
|
57
|
+
sql,
|
58
|
+
obfuscation_limit: config[:obfuscation_limit],
|
59
|
+
adapter: :postgres
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
53
63
|
def tracer
|
54
64
|
PG::Instrumentation.instance.tracer
|
55
65
|
end
|
@@ -112,34 +122,6 @@ module OpenTelemetry
|
|
112
122
|
operation if PG::Constants::SQL_COMMANDS.include?(operation)
|
113
123
|
end
|
114
124
|
|
115
|
-
def obfuscate_sql(sql)
|
116
|
-
return sql unless config[:db_statement] == :obfuscate
|
117
|
-
|
118
|
-
if sql.size > config[:obfuscation_limit]
|
119
|
-
first_match_index = sql.index(generated_postgres_regex)
|
120
|
-
truncation_message = "SQL truncated (> #{config[:obfuscation_limit]} characters)"
|
121
|
-
return truncation_message unless first_match_index
|
122
|
-
|
123
|
-
truncated_sql = sql[..first_match_index - 1]
|
124
|
-
return "#{truncated_sql}...\n#{truncation_message}"
|
125
|
-
end
|
126
|
-
|
127
|
-
# From:
|
128
|
-
# https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscator.rb
|
129
|
-
# https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscation_helpers.rb
|
130
|
-
obfuscated = sql.gsub(generated_postgres_regex, '?')
|
131
|
-
obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if PG::Constants::UNMATCHED_PAIRS_REGEX.match(obfuscated)
|
132
|
-
|
133
|
-
obfuscated
|
134
|
-
rescue StandardError => e
|
135
|
-
OpenTelemetry.handle_error(message: 'Failed to obfuscate SQL', exception: e)
|
136
|
-
'OpenTelemetry error: failed to obfuscate sql'
|
137
|
-
end
|
138
|
-
|
139
|
-
def generated_postgres_regex
|
140
|
-
@generated_postgres_regex ||= Regexp.union(PG::Constants::POSTGRES_COMPONENTS.map { |component| PG::Constants::COMPONENTS_REGEX_MAP[component] })
|
141
|
-
end
|
142
|
-
|
143
125
|
def client_attributes
|
144
126
|
attributes = {
|
145
127
|
'db.system' => 'postgresql',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.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: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-helpers-sql-obfuscation
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: opentelemetry-instrumentation-base
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +184,28 @@ dependencies:
|
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
187
|
+
version: 1.60.1
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 1.60.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop-performance
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '1.20'
|
174
202
|
type: :development
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
206
|
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
208
|
+
version: '1.20'
|
181
209
|
- !ruby/object:Gem::Dependency
|
182
210
|
name: simplecov
|
183
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,10 +257,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
229
257
|
licenses:
|
230
258
|
- Apache-2.0
|
231
259
|
metadata:
|
232
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.
|
260
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.0/file/CHANGELOG.md
|
233
261
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/pg
|
234
262
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
235
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.
|
263
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.0
|
236
264
|
post_install_message:
|
237
265
|
rdoc_options: []
|
238
266
|
require_paths:
|