opentelemetry-instrumentation-pg 0.34.1 → 0.35.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e25165c6bc8420f5e2b28ac6aeb867e0cc64bfe8092b3a4a028d7a6a7c22c5a4
4
- data.tar.gz: 0f272cb7f1594a6521827811a1902ae81f3175b6b226ff792e689d16e92d7b0b
3
+ metadata.gz: 7939f1927799287f8b6aaa52df7b679f48b79e071b890caa729cde97076f4cc7
4
+ data.tar.gz: 5ab484d7f918cb112580e1bd380cff06828d7b24df830e5f87c777300fc0e826
5
5
  SHA512:
6
- metadata.gz: 9f8fce6707481a501a154c1d7c1dee4cab68ba54d5ab7f6916e0c836ba80b700611d3fa3d12650a9523b8820788037713d1eedb187b2783e72c8e2f47b76bddb
7
- data.tar.gz: 47ea8a80aca36ad7a299366e74d7085021d261658b0894800656ab022d401772c9f2b0af48e1ddf78c01fcebbae2914c94e255ec2b5e59bc9309aee0579b2973
6
+ metadata.gz: 773ad26dd2a8ee92c2abd59453c7ccd3d5ca2cbaf6766ac085a29e4c1c09f446d38a9b7e6a612243ea5c3488b5d8afc87ddc0384a9c27b9410f6afb3d49ec6a2
7
+ data.tar.gz: 4a63ed8c931d8f4fd7f73b162d804da1285e211e28fde2631acf975a93344139c6e3694b76870bc22a7eac9c66c74bb41851482b2d6df0360d4c16299b137fc1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-pg
2
2
 
3
+ ### v0.35.0 / 2026-01-13
4
+
5
+ * ADDED: Add SQL Comment Propagator
6
+
3
7
  ### v0.34.1 / 2025-12-03
4
8
 
5
9
  * FIXED: Update gemspec dependencies to sql-processor
data/README.md CHANGED
@@ -80,4 +80,3 @@ The `opentelemetry-instrumentation-pg` gem is distributed under the Apache 2.0 l
80
80
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
81
81
  [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
82
82
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
83
-
@@ -11,9 +11,10 @@ module OpenTelemetry
11
11
  class Instrumentation < OpenTelemetry::Instrumentation::Base
12
12
  MINIMUM_VERSION = Gem::Version.new('1.1.0')
13
13
 
14
- install do |_config|
14
+ install do |config|
15
15
  require_dependencies
16
16
  patch_client
17
+ configure_propagator(config)
17
18
  end
18
19
 
19
20
  present do
@@ -27,6 +28,9 @@ module OpenTelemetry
27
28
  option :peer_service, default: nil, validate: :string
28
29
  option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate]
29
30
  option :obfuscation_limit, default: 2000, validate: :integer
31
+ option :propagator, default: 'none', validate: %w[none tracecontext]
32
+
33
+ attr_reader :propagator
30
34
 
31
35
  private
32
36
 
@@ -42,6 +46,16 @@ module OpenTelemetry
42
46
  ::PG::Connection.prepend(Patches::Connection)
43
47
  ::PG::Connection.singleton_class.prepend(Patches::Connect)
44
48
  end
49
+
50
+ def configure_propagator(config)
51
+ propagator = config[:propagator]
52
+ @propagator = case propagator
53
+ when 'tracecontext' then OpenTelemetry::Helpers::SqlProcessor::SqlCommenter.sql_query_propagator
54
+ when 'none', nil then nil
55
+ else
56
+ OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
57
+ end
58
+ end
45
59
  end
46
60
  end
47
61
  end
@@ -79,7 +79,20 @@ module OpenTelemetry
79
79
  PG::Constants::EXEC_ISH_METHODS.each do |method|
80
80
  define_method method do |*args, &block|
81
81
  span_name, attrs = span_attrs(:query, *args)
82
- tracer.in_span(span_name, attributes: attrs, kind: :client) do
82
+ tracer.in_span(span_name, attributes: attrs, kind: :client) do |_span, context|
83
+ # Inject propagator context into SQL if propagator is configured
84
+ if propagator && args[0].is_a?(String)
85
+ sql = args[0]
86
+ if sql.frozen?
87
+ sql = +sql
88
+ propagator.inject(sql, context: context)
89
+ sql.freeze
90
+ args[0] = sql
91
+ else
92
+ propagator.inject(sql, context: context)
93
+ end
94
+ end
95
+
83
96
  if block
84
97
  block.call(super(*args))
85
98
  else
@@ -92,7 +105,21 @@ module OpenTelemetry
92
105
  PG::Constants::PREPARE_ISH_METHODS.each do |method|
93
106
  define_method method do |*args|
94
107
  span_name, attrs = span_attrs(:prepare, *args)
95
- tracer.in_span(span_name, attributes: attrs, kind: :client) do
108
+ tracer.in_span(span_name, attributes: attrs, kind: :client) do |_span, context|
109
+ # Inject propagator context into SQL if propagator is configured
110
+ # For prepare, the SQL is in args[1]
111
+ if propagator && args[1].is_a?(String)
112
+ sql = args[1]
113
+ if sql.frozen?
114
+ sql = +sql
115
+ propagator.inject(sql, context: context)
116
+ sql.freeze
117
+ args[1] = sql
118
+ else
119
+ propagator.inject(sql, context: context)
120
+ end
121
+ end
122
+
96
123
  super(*args)
97
124
  end
98
125
  end
@@ -248,6 +275,10 @@ module OpenTelemetry
248
275
  p = conninfo_hash[:port]
249
276
  p.to_i unless p.nil? || p.empty? || p.include?(',')
250
277
  end
278
+
279
+ def propagator
280
+ OpenTelemetry::Instrumentation::PG::Instrumentation.instance.propagator
281
+ end
251
282
  end
252
283
  end
253
284
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module PG
10
- VERSION = '0.34.1'
10
+ VERSION = '0.35.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.34.1
4
+ version: 0.35.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-12-03 00:00:00.000000000 Z
11
+ date: 2026-01-13 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.34.1/file/CHANGELOG.md
78
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.35.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.34.1
81
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-pg/0.35.0
82
82
  post_install_message:
83
83
  rdoc_options: []
84
84
  require_paths: