opentelemetry-instrumentation-pg 0.26.1 → 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: 399267fa1f2c8f3206b97b7896f1631d26b4c561d9e7981b225e17ee71d9e028
4
- data.tar.gz: ae172b55cd0b320c98baad746078ded1807400e02d16a04ecaa59018ae27fada
3
+ metadata.gz: 4bc1cf9d4064f6c7acdf160a45b360347c5ad87ffad97a63e086ccea564b396c
4
+ data.tar.gz: 5bf6eb9b540fd53b53d51126ebd8cce58cc640587f9a9ab7bc3aea9a20026a74
5
5
  SHA512:
6
- metadata.gz: a2c3d21103e6a462bca6f11703c9534536ee90bdea021341456a1e940b8cefd52ff7e416db0a3bbc32e198886e2c2ac8a411dc9ae65d195fa589f054ee7b6602
7
- data.tar.gz: e40016fcb937d5807cddc5029abf6b49bee50e4244df916e2e93e554f15c7c849ac5a703bed4efc60c56843b5d66b672dc731f8c5166f5418107e7070166c6f4
6
+ metadata.gz: 0f870b5c594e85710a9e71f514ae37059d679601d1d381f5854baf054f780b7504777b12a40e09decbd295852dc9c0b1bb951e97588e8d61b4dfd7e1f8b88f00
7
+ data.tar.gz: 62479ce766cf77cae8ea0854443d2a71882c9bc1995749c2f07bca70b4890cda2c91d18f1e45e0d27923652111a77257f5aa80e4caa88356f2574680e2647fce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
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
+
3
8
  ### v0.26.1 / 2023-11-23
4
9
 
5
10
  * CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
@@ -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',
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module PG
10
- VERSION = '0.26.1'
10
+ VERSION = '0.27.0'
11
11
  end
12
12
  end
13
13
  end
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.26.1
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: 2023-11-23 00:00:00.000000000 Z
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,28 +184,28 @@ dependencies:
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: 1.56.1
187
+ version: 1.60.1
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: 1.56.1
194
+ version: 1.60.1
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: rubocop-performance
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - "~>"
186
200
  - !ruby/object:Gem::Version
187
- version: 1.19.1
201
+ version: '1.20'
188
202
  type: :development
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - "~>"
193
207
  - !ruby/object:Gem::Version
194
- version: 1.19.1
208
+ version: '1.20'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: simplecov
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -243,10 +257,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
243
257
  licenses:
244
258
  - Apache-2.0
245
259
  metadata:
246
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.26.1/file/CHANGELOG.md
260
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.0/file/CHANGELOG.md
247
261
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/pg
248
262
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
249
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.26.1
263
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.0
250
264
  post_install_message:
251
265
  rdoc_options: []
252
266
  require_paths: