-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch Core::Telemetry::Http::Adapters::Net to avoid WebMock automatic…
…ally
- Loading branch information
1 parent
6c65eb0
commit 4e78d3d
Showing
7 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module CI | ||
module Transport | ||
module Adapters | ||
module NetHttpClient | ||
def self.original_net_http | ||
return ::Net::HTTP unless defined?(WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP) | ||
|
||
WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
lib/datadog/ci/transport/adapters/telemetry_webmock_safe_adapter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "net_http_client" | ||
|
||
module Datadog | ||
module CI | ||
module Transport | ||
module Adapters | ||
module TelemetryWebmockSafeAdapter | ||
def self.included(base) | ||
base.prepend(InstanceMethods) | ||
end | ||
|
||
module InstanceMethods | ||
def open(&block) | ||
req = NetHttpClient.original_net_http.new(@hostname, @port) | ||
|
||
req.use_ssl = @ssl | ||
req.open_timeout = req.read_timeout = @timeout | ||
|
||
req.start(&block) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Datadog | ||
module CI | ||
module Transport | ||
module Adapters | ||
module NetHttpClient | ||
def self.original_net_http: () -> singleton(Net::HTTP) | ||
end | ||
end | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
sig/datadog/ci/transport/adapters/telemetry_webmock_safe_adapter.rbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Datadog | ||
module CI | ||
module Transport | ||
module Adapters | ||
module TelemetryWebmockSafeAdapter | ||
def self.included: (untyped base) -> untyped | ||
|
||
module InstanceMethods : Datadog::Core::Telemetry::Http::Adapters::Net | ||
def open: () { (?) -> untyped } -> untyped | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |