opentelemetry-instrumentation-pg 0.27.4 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +5 -3
- data/lib/opentelemetry/instrumentation/pg/patches/connection.rb +15 -3
- data/lib/opentelemetry/instrumentation/pg/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd590dfd1d522e383d0ddfa5cebfe6aed7eff09c632bc883d757542e1bc13cbd
|
4
|
+
data.tar.gz: 1e92bbd9721812c0a84dee04d65e8a309e43f0f7339dde999043314e82c9c4ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c35f30669b2d8061047eb99b968b7d5483ea074b31d1715e0606b201aebf51d88038ee1db72ad72e7e2ead657e4adcf5f8f4b6e340196964aecd09625e2492e
|
7
|
+
data.tar.gz: 9de710fac153a36bae0f105b9ba4db66c8db5d25861679fa6849eb61006d3d53d50b05712594f8a1d182dbc5df5f3b1cde5dca87eb5ce6def46ce6dfe57bb187
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-pg
|
2
2
|
|
3
|
+
### v0.28.0 / 2024-08-15
|
4
|
+
|
5
|
+
* ADDED: Collect pg db.collection_name attribute
|
6
|
+
* FIXED: Update versions to be tested (includes drop support for pg 1.2)
|
7
|
+
|
3
8
|
### v0.27.4 / 2024-07-23
|
4
9
|
|
5
10
|
* DOCS: Add cspell to CI
|
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
|
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
|
-
[
|
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(
|
91
|
-
sql = obfuscate_sql(
|
95
|
+
operation = extract_operation(text)
|
96
|
+
sql = obfuscate_sql(text).to_s
|
92
97
|
else
|
93
|
-
statement_name =
|
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',
|
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.28.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-
|
11
|
+
date: 2024-08-15 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:
|
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:
|
68
|
+
version: 6.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: appraisal
|
71
71
|
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.
|
246
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.28.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.
|
249
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.28.0
|
250
250
|
post_install_message:
|
251
251
|
rdoc_options: []
|
252
252
|
require_paths:
|