opentelemetry-instrumentation-pg 0.31.1 → 0.33.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +2 -2
- data/lib/opentelemetry/instrumentation/pg/constants.rb +6 -0
- data/lib/opentelemetry/instrumentation/pg/instrumentation.rb +1 -0
- data/lib/opentelemetry/instrumentation/pg/patches/connection.rb +59 -0
- 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: 55eea698a5680444c893b9ff4bfafcd490f179418b3d84df63eb49737eb89b11
|
|
4
|
+
data.tar.gz: 332bb5e30ee14d66fb880f7645afbee4a5646e1b1e70d16a39d27aba37d5baee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8be801a269c94650a3cec4362a551e3f89428956bb20aa988b8196952ff4322ca4eeceb186c62bb8156c616627ecf5a8d954d218fefacfb647643070df7f8aa6
|
|
7
|
+
data.tar.gz: dd5824d49a288621a39cdaaac75aae220e85029cf9a07a5b13bab8f40f9b12021ecfea3477e040f1ace8e3cd070f0218622fc329bb130226bd77c9a29bc15c9f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Release History: opentelemetry-instrumentation-pg
|
|
2
2
|
|
|
3
|
+
### v0.33.0 / 2025-11-03
|
|
4
|
+
|
|
5
|
+
* ADDED: Instrument PG connect
|
|
6
|
+
|
|
7
|
+
### v0.32.0 / 2025-10-22
|
|
8
|
+
|
|
9
|
+
* BREAKING CHANGE: Min Ruby Version 3.2
|
|
10
|
+
|
|
11
|
+
* ADDED: Min Ruby Version 3.2
|
|
12
|
+
|
|
3
13
|
### v0.31.1 / 2025-09-30
|
|
4
14
|
|
|
5
15
|
* FIXED: Min OTel Ruby API 1.7
|
data/README.md
CHANGED
|
@@ -50,9 +50,9 @@ OpenTelemetry::SDK.configure do |c|
|
|
|
50
50
|
# will be included on all spans from this instrumentation:
|
|
51
51
|
peer_service: 'postgres:readonly',
|
|
52
52
|
|
|
53
|
-
# By default, this instrumentation
|
|
53
|
+
# By default, this instrumentation obfuscates/sanitizes the executed SQL as the `db.statement`
|
|
54
54
|
# semantic attribute. Optionally, you may disable the inclusion of this attribute entirely by
|
|
55
|
-
# setting this option to :omit or
|
|
55
|
+
# setting this option to :omit or disable sanitization of the attribute by setting it to :include
|
|
56
56
|
db_statement: :include,
|
|
57
57
|
}
|
|
58
58
|
end
|
|
@@ -12,6 +12,65 @@ module OpenTelemetry
|
|
|
12
12
|
module Instrumentation
|
|
13
13
|
module PG
|
|
14
14
|
module Patches
|
|
15
|
+
# Utility methods for setting connection attributes from Connect module
|
|
16
|
+
module ConnectionHelper
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
def set_connection_attributes(span, conn, config)
|
|
20
|
+
attributes = {
|
|
21
|
+
'db.system' => 'postgresql',
|
|
22
|
+
'db.name' => conn.db,
|
|
23
|
+
'db.user' => conn.user
|
|
24
|
+
}
|
|
25
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
|
26
|
+
|
|
27
|
+
h = conn.host
|
|
28
|
+
if h&.start_with?('/')
|
|
29
|
+
attributes['net.sock.family'] = 'unix'
|
|
30
|
+
attributes['net.peer.name'] = h
|
|
31
|
+
else
|
|
32
|
+
attributes['net.transport'] = 'ip_tcp'
|
|
33
|
+
attributes['net.peer.name'] = h
|
|
34
|
+
attributes['net.peer.port'] = conn.port if defined?(::PG::DEF_PGPORT)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
attributes.merge!(OpenTelemetry::Instrumentation::PG.attributes)
|
|
38
|
+
attributes.compact!
|
|
39
|
+
|
|
40
|
+
span.add_attributes(attributes)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Module to prepend to PG::Connection singleton class for connection initialization
|
|
45
|
+
# We override `new` instead of `initialize` because PG::Connection.new is implemented
|
|
46
|
+
# as a Ruby method that calls the C-level connect_start, bypassing initialize.
|
|
47
|
+
# We also need to override the aliases (open, connect, async_connect) because they
|
|
48
|
+
# were aliased before our prepend, so they point to the original method.
|
|
49
|
+
# See: https://github.com/ged/ruby-pg/blob/master/lib/pg/connection.rb#L870
|
|
50
|
+
module Connect
|
|
51
|
+
def new(...)
|
|
52
|
+
tracer = OpenTelemetry::Instrumentation::PG::Instrumentation.instance.tracer
|
|
53
|
+
config = OpenTelemetry::Instrumentation::PG::Instrumentation.instance.config
|
|
54
|
+
|
|
55
|
+
tracer.in_span('connect', kind: :client) do |span|
|
|
56
|
+
if block_given?
|
|
57
|
+
super do |conn|
|
|
58
|
+
ConnectionHelper.set_connection_attributes(span, conn, config)
|
|
59
|
+
yield conn
|
|
60
|
+
end
|
|
61
|
+
else
|
|
62
|
+
conn = super
|
|
63
|
+
ConnectionHelper.set_connection_attributes(span, conn, config)
|
|
64
|
+
conn
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
PG::Constants::CONNECTION_METHODS.each do |method|
|
|
70
|
+
alias_method method, :new
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
15
74
|
# Module to prepend to PG::Connection for instrumentation
|
|
16
75
|
module Connection # rubocop:disable Metrics/ModuleLength
|
|
17
76
|
# Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands
|
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.33.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: 2025-
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: opentelemetry-helpers-sql
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0.
|
|
47
|
+
version: '0.25'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
54
|
+
version: '0.25'
|
|
55
55
|
description: PG (PostgreSQL) instrumentation for the OpenTelemetry framework
|
|
56
56
|
email:
|
|
57
57
|
- cncf-opentelemetry-contributors@lists.cncf.io
|
|
@@ -75,10 +75,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
|
75
75
|
licenses:
|
|
76
76
|
- Apache-2.0
|
|
77
77
|
metadata:
|
|
78
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.
|
|
78
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.33.0/file/CHANGELOG.md
|
|
79
79
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/pg
|
|
80
80
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
81
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.
|
|
81
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.33.0
|
|
82
82
|
post_install_message:
|
|
83
83
|
rdoc_options: []
|
|
84
84
|
require_paths:
|
|
@@ -87,14 +87,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
87
87
|
requirements:
|
|
88
88
|
- - ">="
|
|
89
89
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '3.
|
|
90
|
+
version: '3.2'
|
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - ">="
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version: 3.
|
|
97
|
+
rubygems_version: 3.4.19
|
|
98
98
|
signing_key:
|
|
99
99
|
specification_version: 4
|
|
100
100
|
summary: PG (PostgreSQL) instrumentation for the OpenTelemetry framework
|