opentelemetry-instrumentation-pg 0.27.4 → 0.29.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: 2187ac9ab422a74e19649ecd640402256df3fb1d7612c085505a27c7338f8466
4
- data.tar.gz: 98499058df88381568fec937169996a045869c6fbfb90a85db754e9fd53d674e
3
+ metadata.gz: dbd4b5e3db4cf1c343418ffe7121c94565f238c59d6ba85f063b1ef1b0e71f17
4
+ data.tar.gz: 149ea8294e6817584074e096bfc457ef6983c2cbd649fddabcbed0c9d1ac2972
5
5
  SHA512:
6
- metadata.gz: c9df84e9dcce11d2893ef9623cb2e23ddae0eb12fb8f881c7f792f62b461105d9e1205848dc5bd395607db5e3845dab1fac7f8dfc00e0b4ad7665c1df414531d
7
- data.tar.gz: 9ef15614badb43be8b8dcc43e36672008cae7dc9c03bbd0bd12249971361c0e22c0cbd2a495cae66ccf4221a76b3df743e307ccbe7b004bc8e5e4ee87ee67d1d
6
+ metadata.gz: 65613566f733495499b510c2679c3271778d4af51513db01b381fe606c08059cb9d474adaa0d09378658c6f6adfa86dbbe6d684026d0a3ebdff118ca188be046
7
+ data.tar.gz: d500d2cfd32952525f330d2ced9227f14c6c9ba2bd4619e5fb995cf88606fcc6704bae716633dcc2f5136ee41d286acd0f8869de99b3aa97f9eea0736e6f6340
data/CHANGELOG.md CHANGED
@@ -1,117 +1,125 @@
1
1
  # Release History: opentelemetry-instrumentation-pg
2
2
 
3
+ ### v0.29.0 / 2024-09-12
4
+
5
+ - BREAKING CHANGE: Return message when sql is over the obfuscation limit. Fixes a bug where sql statements with prepended comments that hit the obfuscation limit would be sent raw.
6
+
7
+ ### v0.28.0 / 2024-08-15
8
+
9
+ - ADDED: Collect pg db.collection_name attribute
10
+ - FIXED: Update versions to be tested (includes drop support for pg 1.2)
11
+
3
12
  ### v0.27.4 / 2024-07-23
4
13
 
5
- * DOCS: Add cspell to CI
14
+ - DOCS: Add cspell to CI
6
15
 
7
16
  ### v0.27.3 / 2024-05-11
8
17
 
9
- * ADDED: Support prepend SQL comment for PG instrumentation
18
+ - ADDED: Support prepend SQL comment for PG instrumentation
10
19
 
11
20
  ### v0.27.2 / 2024-04-30
12
21
 
13
- * FIXED: Bundler conflict warnings
22
+ - FIXED: Bundler conflict warnings
14
23
 
15
24
  ### v0.27.1 / 2024-02-08
16
25
 
17
- * FIXED: Add missing requires for sql-helpers to mysql, pg, and trilogy instrumentation
26
+ - FIXED: Add missing requires for sql-helpers to mysql, pg, and trilogy instrumentation
18
27
 
19
28
  ### v0.27.0 / 2024-02-08
20
29
 
21
- * BREAKING CHANGE: Move shared sql behavior to helper gems
22
-
30
+ - BREAKING CHANGE: Move shared sql behavior to helper gems
23
31
 
24
32
  ### v0.26.1 / 2023-11-23
25
33
 
26
- * CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
34
+ - CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
27
35
 
28
36
  ### v0.26.0 / 2023-10-16
29
37
 
30
- * BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement
38
+ - BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement
31
39
 
32
- * ADDED: Obfuscation for mysql2, dalli and postgresql as default option for db_statement
40
+ - ADDED: Obfuscation for mysql2, dalli and postgresql as default option for db_statement
33
41
 
34
42
  ### v0.25.3 / 2023-07-29
35
43
 
36
- * FIXED: Pass block explicitly in `define_method` calls for PG instrumentation query methods
44
+ - FIXED: Pass block explicitly in `define_method` calls for PG instrumentation query methods
37
45
 
38
46
  ### v0.25.2 / 2023-06-05
39
47
 
40
- * FIXED: Base config options
48
+ - FIXED: Base config options
41
49
 
42
50
  ### v0.25.1 / 2023-06-01
43
51
 
44
- * FIXED: Regex non-match with obfuscation limit (issue #486)
52
+ - FIXED: Regex non-match with obfuscation limit (issue #486)
45
53
 
46
54
  ### v0.25.0 / 2023-05-25
47
55
 
48
- * ADDED: Add config[:obfuscation_limit] to pg and mysql2
56
+ - ADDED: Add config[:obfuscation_limit] to pg and mysql2
49
57
 
50
58
  ### v0.24.0 / 2023-04-17
51
59
 
52
- * BREAKING CHANGE: Drop support for EoL Ruby 2.7
60
+ - BREAKING CHANGE: Drop support for EoL Ruby 2.7
53
61
 
54
- * ADDED: Drop support for EoL Ruby 2.7
62
+ - ADDED: Drop support for EoL Ruby 2.7
55
63
 
56
64
  ### v0.23.0 / 2023-01-14
57
65
 
58
- * BREAKING CHANGE: Removed deprecated instrumentation options
66
+ - BREAKING CHANGE: Removed deprecated instrumentation options
59
67
 
60
- * ADDED: Removed deprecated instrumentation options
61
- * FIXED: Reduce Hash Allocations in PG Instrumentation
62
- * DOCS: Fix gem homepage
63
- * DOCS: More gem documentation fixes
68
+ - ADDED: Removed deprecated instrumentation options
69
+ - FIXED: Reduce Hash Allocations in PG Instrumentation
70
+ - DOCS: Fix gem homepage
71
+ - DOCS: More gem documentation fixes
64
72
 
65
73
  ### v0.22.3 / 2022-12-06
66
74
 
67
- * FIXED: Use attributes from the active PG connection
75
+ - FIXED: Use attributes from the active PG connection
68
76
 
69
77
  ### v0.22.2 / 2022-11-10
70
78
 
71
- * FIXED: Safeguard against host being nil
79
+ - FIXED: Safeguard against host being nil
72
80
 
73
81
  ### v0.22.1 / 2022-10-27
74
82
 
75
- * FIXED: Only take the first item in a comma-separated list for pg attrs
83
+ - FIXED: Only take the first item in a comma-separated list for pg attrs
76
84
 
77
85
  ### v0.22.0 / 2022-10-04
78
86
 
79
- * ADDED: Add `with_attributes` context propagation for PG instrumentation
87
+ - ADDED: Add `with_attributes` context propagation for PG instrumentation
80
88
 
81
89
  ### v0.21.0 / 2022-06-09
82
90
 
83
- * Upgrading Base dependency version
84
- * FIXED: Broken test file requirements
91
+ - Upgrading Base dependency version
92
+ - FIXED: Broken test file requirements
85
93
 
86
94
  ### v0.20.0 / 2022-05-02
87
95
 
88
- * ADDED: Validate Using Enums
89
- * FIXED: Update pg instrumentation to handle non primitive argument
90
- * FIXED: RubyGems Fallback
96
+ - ADDED: Validate Using Enums
97
+ - FIXED: Update pg instrumentation to handle non primitive argument
98
+ - FIXED: RubyGems Fallback
91
99
 
92
100
  ### v0.19.2 / 2021-12-02
93
101
 
94
- * (No significant changes)
102
+ - (No significant changes)
95
103
 
96
104
  ### v0.19.1 / 2021-09-29
97
105
 
98
- * (No significant changes)
106
+ - (No significant changes)
99
107
 
100
108
  ### v0.19.0 / 2021-08-12
101
109
 
102
- * ADDED: Add db_statement toggle for postgres
103
- * DOCS: Update docs to rely more on environment variable configuration
110
+ - ADDED: Add db_statement toggle for postgres
111
+ - DOCS: Update docs to rely more on environment variable configuration
104
112
 
105
113
  ### v0.18.1 / 2021-06-23
106
114
 
107
- * (No significant changes)
115
+ - (No significant changes)
108
116
 
109
117
  ### v0.18.0 / 2021-05-21
110
118
 
111
- * ADDED: Updated API dependency for 1.0.0.rc1
112
- * ADDED: Add option to postgres instrumentation to disable db.statement
119
+ - ADDED: Updated API dependency for 1.0.0.rc1
120
+ - ADDED: Add option to postgres instrumentation to disable db.statement
113
121
 
114
122
  ### v0.17.1 / 2021-04-23
115
123
 
116
- * Initial release.
117
- * ADDED: Initial postgresql instrumentation
124
+ - Initial release.
125
+ - ADDED: Initial postgresql instrumentation
data/README.md CHANGED
@@ -6,7 +6,7 @@ The OpenTelemetry PG Ruby gem is a community maintained instrumentation for [PG]
6
6
 
7
7
  Install the gem using:
8
8
 
9
- ```
9
+ ```console
10
10
  gem install opentelemetry-instrumentation-pg
11
11
  ```
12
12
 
@@ -66,7 +66,7 @@ An example of usage can be seen in [`example/pg.rb`](https://github.com/open-tel
66
66
 
67
67
  The `opentelemetry-instrumentation-pg` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
68
68
 
69
- 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].
69
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our [GitHub Discussions][discussions-url], [Slack Channel][slack-channel] 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].
70
70
 
71
71
  ## License
72
72
 
@@ -78,4 +78,6 @@ The `opentelemetry-instrumentation-pg` gem is distributed under the Apache 2.0 l
78
78
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
79
79
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
80
80
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
81
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
81
+ [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
82
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
83
+
@@ -14,6 +14,9 @@ module OpenTelemetry
14
14
  module Patches
15
15
  # Module to prepend to PG::Connection for instrumentation
16
16
  module Connection # rubocop:disable Metrics/ModuleLength
17
+ # Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands
18
+ TABLE_NAME = /\b(?:FROM|INTO|UPDATE|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|DROP\s+TABLE(?:\s+IF\s+EXISTS)?|ALTER\s+TABLE(?:\s+IF\s+EXISTS)?)\s+([\w\.]+)/i
19
+
17
20
  PG::Constants::EXEC_ISH_METHODS.each do |method|
18
21
  define_method method do |*args, &block|
19
22
  span_name, attrs = span_attrs(:query, *args)
@@ -86,11 +89,13 @@ module OpenTelemetry
86
89
  # module size limit! We can't win here unless we want to start
87
90
  # abstracting things into a million pieces.
88
91
  def span_attrs(kind, *args)
92
+ text = args[0]
93
+
89
94
  if kind == :query
90
- operation = extract_operation(args[0])
91
- sql = obfuscate_sql(args[0]).to_s
95
+ operation = extract_operation(text)
96
+ sql = obfuscate_sql(text).to_s
92
97
  else
93
- statement_name = args[0]
98
+ statement_name = text
94
99
 
95
100
  if kind == :prepare
96
101
  sql = obfuscate_sql(args[1]).to_s
@@ -104,6 +109,7 @@ module OpenTelemetry
104
109
 
105
110
  attrs = { 'db.operation' => validated_operation(operation), 'db.postgresql.prepared_statement_name' => statement_name }
106
111
  attrs['db.statement'] = sql unless config[:db_statement] == :omit
112
+ attrs['db.collection.name'] = collection_name(text)
107
113
  attrs.merge!(OpenTelemetry::Instrumentation::PG.attributes)
108
114
  attrs.compact!
109
115
 
@@ -125,6 +131,12 @@ module OpenTelemetry
125
131
  operation if PG::Constants::SQL_COMMANDS.include?(operation)
126
132
  end
127
133
 
134
+ def collection_name(text)
135
+ text.scan(TABLE_NAME).flatten[0]
136
+ rescue StandardError
137
+ nil
138
+ end
139
+
128
140
  def client_attributes
129
141
  attributes = {
130
142
  'db.system' => 'postgresql',
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module PG
10
- VERSION = '0.27.4'
10
+ VERSION = '0.29.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.27.4
4
+ version: 0.29.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: 2024-07-24 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 6.1.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ">"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 6.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: appraisal
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 1.65.0
173
+ version: 1.66.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 1.65.0
180
+ version: 1.66.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop-performance
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -243,10 +243,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
243
243
  licenses:
244
244
  - Apache-2.0
245
245
  metadata:
246
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.4/file/CHANGELOG.md
246
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.29.0/file/CHANGELOG.md
247
247
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/pg
248
248
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
249
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.27.4
249
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.29.0
250
250
  post_install_message:
251
251
  rdoc_options: []
252
252
  require_paths: