Skip to content

Commit 22089f8

Browse files
Merge branch 'main' into feature/active_storage_support
2 parents e09519c + 14a6d96 commit 22089f8

File tree

12 files changed

+18
-109
lines changed

12 files changed

+18
-109
lines changed

instrumentation/mysql2/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gemspec
1010

1111
group :test, :development do
1212
gem 'opentelemetry-instrumentation-base', path: '../base'
13+
gem 'opentelemetry-helpers-sql', path: '../../helpers/sql'
1314
gem 'opentelemetry-helpers-mysql', path: '../../helpers/mysql'
1415
gem 'opentelemetry-helpers-sql-obfuscation', path: '../../helpers/sql-obfuscation'
1516
end

instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2.rb

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,13 @@
66

77
require 'opentelemetry'
88
require 'opentelemetry-instrumentation-base'
9+
require 'opentelemetry-helpers-sql'
910

1011
module OpenTelemetry
1112
module Instrumentation
1213
# Contains the OpenTelemetry instrumentation for the Mysql2 gem
1314
module Mysql2
14-
extend self
15-
16-
CURRENT_ATTRIBUTES_KEY = Context.create_key('mysql-attributes-hash')
17-
18-
private_constant :CURRENT_ATTRIBUTES_KEY
19-
20-
# Returns the attributes hash representing the Mysql2 context found
21-
# in the optional context or the current context if none is provided.
22-
#
23-
# @param context [optional Context] The context to lookup the current
24-
# attributes hash. Defaults to Context.current
25-
def attributes(context = nil)
26-
context ||= Context.current
27-
context.value(CURRENT_ATTRIBUTES_KEY) || {}
28-
end
29-
30-
# @param attributes_hash [Hash] The attributes to add to the context
31-
# @param parent_context [optional Context] The context to use as the parent for
32-
# the returned context
33-
# @return A context containing the merged attributes hash, derived from the
34-
# optional parent context, or the current context if one was not provided.
35-
def context_with_attributes(attributes_hash, parent_context: Context.current)
36-
attributes_hash = attributes(parent_context).merge(attributes_hash)
37-
parent_context.set_value(CURRENT_ATTRIBUTES_KEY, attributes_hash)
38-
end
39-
40-
# Activates/deactivates the merged attributes hash within the current Context,
41-
# which makes the "current attributes hash" available implicitly.
42-
#
43-
# On exit, the attributes hash that was active before calling this method
44-
# will be reactivated.
45-
#
46-
# @param [Span] span the span to activate
47-
# @yield [Hash, Context] yields attributes hash and a context containing the
48-
# attributes hash to the block.
49-
def with_attributes(attributes_hash)
50-
attributes_hash = attributes.merge(attributes_hash)
51-
Context.with_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) { |c, h| yield h, c }
52-
end
15+
extend ::OpenTelemetry::Helpers::Sql
5316
end
5417
end
5518
end

instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
2727

2828
spec.add_dependency 'opentelemetry-api', '~> 1.0'
2929
spec.add_dependency 'opentelemetry-helpers-mysql'
30+
spec.add_dependency 'opentelemetry-helpers-sql'
3031
spec.add_dependency 'opentelemetry-helpers-sql-obfuscation'
3132
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.23.0'
3233

instrumentation/pg/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ gemspec
1111
group :test do
1212
gem 'activerecord', '>= 7.0.0'
1313
gem 'opentelemetry-instrumentation-base', path: '../base'
14+
gem 'opentelemetry-helpers-sql', path: '../../helpers/sql'
1415
gem 'opentelemetry-helpers-sql-obfuscation', path: '../../helpers/sql-obfuscation'
1516
end

instrumentation/pg/lib/opentelemetry/instrumentation/pg.rb

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,13 @@
66

77
require 'opentelemetry'
88
require 'opentelemetry-instrumentation-base'
9+
require 'opentelemetry-helpers-sql'
910

1011
module OpenTelemetry
1112
module Instrumentation
1213
# Contains the OpenTelemetry instrumentation for the Pg gem
1314
module PG
14-
extend self
15-
16-
CURRENT_ATTRIBUTES_KEY = Context.create_key('pg-attributes-hash')
17-
18-
private_constant :CURRENT_ATTRIBUTES_KEY
19-
20-
# Returns the attributes hash representing the postgres client context found
21-
# in the optional context or the current context if none is provided.
22-
#
23-
# @param [optional Context] context The context to lookup the current
24-
# attributes hash. Defaults to Context.current
25-
def attributes(context = nil)
26-
context ||= Context.current
27-
context.value(CURRENT_ATTRIBUTES_KEY) || {}
28-
end
29-
30-
# Activates/deactivates the merged attributes hash within the current Context,
31-
# which makes the "current attributes hash" available implicitly.
32-
#
33-
# On exit, the attributes hash that was active before calling this method
34-
# will be reactivated.
35-
#
36-
# @param [Span] span the span to activate
37-
# @yield [Hash, Context] yields attributes hash and a context containing the
38-
# attributes hash to the block.
39-
def with_attributes(attributes_hash)
40-
attributes_hash = attributes.merge(attributes_hash)
41-
Context.with_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) { |c, h| yield h, c }
42-
end
15+
extend ::OpenTelemetry::Helpers::Sql
4316
end
4417
end
4518
end

instrumentation/pg/opentelemetry-instrumentation-pg.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
2626
spec.required_ruby_version = '>= 3.1'
2727

2828
spec.add_dependency 'opentelemetry-api', '~> 1.0'
29+
spec.add_dependency 'opentelemetry-helpers-sql'
2930
spec.add_dependency 'opentelemetry-helpers-sql-obfuscation'
3031
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.23.0'
3132

instrumentation/que/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ gemspec
1111
group :test do
1212
gem 'activerecord', '< 7.2.0', '> 7.0.0'
1313
gem 'pg'
14+
gem 'opentelemetry-helpers-sql', path: '../../helpers/sql'
1415
gem 'opentelemetry-helpers-sql-obfuscation', path: '../../helpers/sql-obfuscation'
1516
gem 'opentelemetry-instrumentation-base', path: '../base'
1617
gem 'opentelemetry-instrumentation-pg', path: '../pg'

instrumentation/rails/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release History: opentelemetry-instrumentation-rails
22

3+
### v0.35.1 / 2025-01-28
4+
5+
* DOCS: Required version in Rails README from 0.24 to 0.34.
6+
37
### v0.35.0 / 2025-01-16
48

59
* BREAKING CHANGE: Drop Support for EoL Rails 6.1

instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module OpenTelemetry
88
module Instrumentation
99
module Rails
10-
VERSION = '0.35.0'
10+
VERSION = '0.35.1'
1111
end
1212
end
1313
end

instrumentation/trilogy/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ gemspec
1111
group :test do
1212
gem 'opentelemetry-instrumentation-base', path: '../base'
1313
gem 'opentelemetry-helpers-mysql', path: '../../helpers/mysql'
14+
gem 'opentelemetry-helpers-sql', path: '../../helpers/sql'
1415
gem 'opentelemetry-helpers-sql-obfuscation', path: '../../helpers/sql-obfuscation'
1516
gem 'opentelemetry-propagator-vitess', path: '../../propagator/vitess'
1617
end

0 commit comments

Comments
 (0)