mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-07-20 00:00:31 -04:00
Compare commits
6 Commits
a3ac1993e9
...
834873638d
Author | SHA1 | Date | |
---|---|---|---|
|
834873638d | ||
|
4618845a97 | ||
|
5db6e28534 | ||
|
fb86669872 | ||
|
013f24ba80 | ||
|
96eae65da1 |
@ -127,18 +127,21 @@ module Datadog::Tracing
|
||||
option :split_by_domain, default: false
|
||||
|
||||
option :enabled do |o|
|
||||
o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) }
|
||||
o.lazy
|
||||
o.type :bool
|
||||
o.env "DD_TRACE_HTTPX_ENABLED"
|
||||
o.default true
|
||||
end
|
||||
|
||||
option :analytics_enabled do |o|
|
||||
o.default { env_to_bool(%w[DD_TRACE_HTTPX_ANALYTICS_ENABLED DD_HTTPX_ANALYTICS_ENABLED], false) }
|
||||
o.lazy
|
||||
o.type :bool
|
||||
o.env "DD_TRACE_HTTPX_ANALYTICS_ENABLED"
|
||||
o.default false
|
||||
end
|
||||
|
||||
option :analytics_sample_rate do |o|
|
||||
o.default { env_to_float(%w[DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE DD_HTTPX_ANALYTICS_SAMPLE_RATE], 1.0) }
|
||||
o.lazy
|
||||
o.type :float
|
||||
o.env "DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE"
|
||||
o.default 1.0
|
||||
end
|
||||
|
||||
if defined?(Datadog::Tracing::Contrib::SpanAttributeSchema)
|
||||
@ -162,7 +165,17 @@ module Datadog::Tracing
|
||||
|
||||
option :distributed_tracing, default: true
|
||||
|
||||
option :error_handler, default: DEFAULT_ERROR_HANDLER
|
||||
if DDTrace::VERSION::STRING >= "1.15.0"
|
||||
option :error_handler do |o|
|
||||
o.type :proc
|
||||
o.default_proc(&DEFAULT_ERROR_HANDLER)
|
||||
end
|
||||
else
|
||||
option :error_handler do |o|
|
||||
o.type :proc
|
||||
o.experimental_default_proc(&DEFAULT_ERROR_HANDLER)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -192,7 +205,7 @@ module Datadog::Tracing
|
||||
class Integration
|
||||
include Contrib::Integration
|
||||
|
||||
MINIMUM_VERSION = Gem::Version.new("0.10.2")
|
||||
MINIMUM_VERSION = Gem::Version.new("1.0.1")
|
||||
|
||||
register_as :httpx
|
||||
|
||||
|
@ -149,17 +149,29 @@ module HTTPX
|
||||
deadline: @options.grpc_deadline,
|
||||
}.merge(opts)
|
||||
|
||||
local_rpc_name = rpc_name.underscore
|
||||
|
||||
session_class = Class.new(self.class) do
|
||||
# define rpc method with ruby style name
|
||||
class_eval(<<-OUT, __FILE__, __LINE__ + 1)
|
||||
def #{rpc_name}(input, **opts) # def grpc_action(input, **opts)
|
||||
rpc_execute("#{rpc_name}", input, **opts) # rpc_execute("grpc_action", input, **opts)
|
||||
end # end
|
||||
def #{local_rpc_name}(input, **opts) # def grpc_action(input, **opts)
|
||||
rpc_execute("#{local_rpc_name}", input, **opts) # rpc_execute("grpc_action", input, **opts)
|
||||
end # end
|
||||
OUT
|
||||
|
||||
# define rpc method with original name
|
||||
unless local_rpc_name == rpc_name
|
||||
class_eval(<<-OUT, __FILE__, __LINE__ + 1)
|
||||
def #{rpc_name}(input, **opts) # def grpcAction(input, **opts)
|
||||
rpc_execute("#{local_rpc_name}", input, **opts) # rpc_execute("grpc_action", input, **opts)
|
||||
end # end
|
||||
OUT
|
||||
end
|
||||
end
|
||||
|
||||
session_class.new(@options.merge(
|
||||
grpc_rpcs: @options.grpc_rpcs.merge(
|
||||
rpc_name.underscore => [rpc_name, input, output, rpc_opts]
|
||||
local_rpc_name => [rpc_name, input, output, rpc_opts]
|
||||
).freeze
|
||||
))
|
||||
end
|
||||
|
@ -102,7 +102,7 @@ class HTTPXAwsSigv4Test < Minitest::Test
|
||||
private
|
||||
|
||||
def sigv4_session(**options)
|
||||
HTTPX.plugin(:aws_sigv4).aws_sigv4_authentication(**{ service: "s3", region: "us-east-1", username: "akid",
|
||||
password: "secret" }.merge(options))
|
||||
HTTPX.plugin(:aws_sigv4).aws_sigv4_authentication(service: "s3", region: "us-east-1", username: "akid",
|
||||
password: "secret", **options)
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,18 @@ module Requests
|
||||
module GRPC
|
||||
include GRPCHelpers
|
||||
|
||||
def test_plugin_grpc_stub_rpc_defines_snake_case_methods
|
||||
server_port = run_rpc(TestService)
|
||||
grpc = grpc_plugin
|
||||
|
||||
# build service
|
||||
stub = grpc.build_stub("localhost:#{server_port}")
|
||||
|
||||
sv = stub.rpc(:aCamelCaseRpc, EchoMsg, EchoMsg, marshal_method: :marshal, unmarshal_method: :unmarshal)
|
||||
assert sv.respond_to? :a_camel_case_rpc
|
||||
assert sv.respond_to? :aCamelCaseRpc
|
||||
end
|
||||
|
||||
def test_plugin_grpc_unary_plain_bytestreams
|
||||
no_marshal = proc { |x| x }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user