opentelemetry-instrumentation-pg 0.32.0 → 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 +4 -0
- 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 +4 -4
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
|
@@ -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
|
|
@@ -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:
|