Skip to content

Commit 91e068b

Browse files
authored
Merge branch 'main' into issues-1277
2 parents 63abf7a + 97955b0 commit 91e068b

File tree

6 files changed

+18
-35
lines changed

6 files changed

+18
-35
lines changed

instrumentation/faraday/Appraisals

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# SPDX-License-Identifier: Apache-2.0
66

7-
%w[0.17.6 1.0 2.0].each do |version|
7+
%w[1.0 2.0].each do |version|
88
appraise "faraday-#{version}" do
99
gem 'faraday', "~> #{version}"
1010
end

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ module Faraday
1010
# The Instrumentation class contains logic to detect and install the Faraday
1111
# instrumentation
1212
class Instrumentation < OpenTelemetry::Instrumentation::Base
13+
MINIMUM_VERSION = Gem::Version.new('1.0')
14+
1315
install do |_config|
1416
require_dependencies
1517
register_tracer_middleware
1618
use_middleware_by_default
1719
end
1820

21+
compatible do
22+
gem_version >= MINIMUM_VERSION
23+
end
24+
1925
present do
2026
defined?(::Faraday)
2127
end
@@ -25,10 +31,13 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
2531

2632
private
2733

34+
def gem_version
35+
Gem::Version.new(::Faraday::VERSION)
36+
end
37+
2838
def require_dependencies
2939
require_relative 'middlewares/tracer_middleware'
3040
require_relative 'patches/connection'
31-
require_relative 'patches/rack_builder'
3241
end
3342

3443
def register_tracer_middleware
@@ -38,11 +47,7 @@ def register_tracer_middleware
3847
end
3948

4049
def use_middleware_by_default
41-
if Gem::Version.new(::Faraday::VERSION) >= Gem::Version.new('1')
42-
::Faraday::Connection.prepend(Patches::Connection)
43-
else
44-
::Faraday::RackBuilder.prepend(Patches::RackBuilder)
45-
end
50+
::Faraday::Connection.prepend(Patches::Connection)
4651
end
4752
end
4853
end

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Patches
1313
module Connection
1414
# Wraps Faraday::Connection#initialize:
1515
# https://github.com/lostisland/faraday/blob/ff9dc1d1219a1bbdba95a9a4cf5d135b97247ee2/lib/faraday/connection.rb#L62-L92
16-
def initialize(*args)
16+
def initialize(...)
1717
super.tap do
1818
use(:open_telemetry) unless builder.handlers.any? do |handler|
1919
handler.klass == Middlewares::TracerMiddleware

instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ module Constants
4040
LISTEN
4141
LOAD
4242
LOCK
43+
MERGE
4344
MOVE
4445
NOTIFY
4546
PREPARE
46-
PREPARE
4747
REASSIGN
4848
REFRESH
4949
REINDEX
@@ -54,7 +54,6 @@ module Constants
5454
SAVEPOINT
5555
SECURITY
5656
SELECT
57-
SELECT
5857
SET
5958
SHOW
6059
START

instrumentation/pg/test/fixtures/sql_table_name.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,9 @@
5454
{
5555
"name": "table_name_with_double_quotes",
5656
"sql": "SELECT columns FROM \"test_table\""
57+
},
58+
{
59+
"name": "merge",
60+
"sql": "MERGE INTO test_table AS t USING other_table AS o ON (o.id = t.id) WHEN MATCHED THEN UPDATE SET x = t.x + 1 WHEN NOT MATCHED THEN INSERT (id, x, status) VALUES (o.id, o.x, o.status)"
5761
}
5862
]

0 commit comments

Comments
 (0)