mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-07-21 00:00:40 -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 :split_by_domain, default: false
|
||||||
|
|
||||||
option :enabled do |o|
|
option :enabled do |o|
|
||||||
o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) }
|
o.type :bool
|
||||||
o.lazy
|
o.env "DD_TRACE_HTTPX_ENABLED"
|
||||||
|
o.default true
|
||||||
end
|
end
|
||||||
|
|
||||||
option :analytics_enabled do |o|
|
option :analytics_enabled do |o|
|
||||||
o.default { env_to_bool(%w[DD_TRACE_HTTPX_ANALYTICS_ENABLED DD_HTTPX_ANALYTICS_ENABLED], false) }
|
o.type :bool
|
||||||
o.lazy
|
o.env "DD_TRACE_HTTPX_ANALYTICS_ENABLED"
|
||||||
|
o.default false
|
||||||
end
|
end
|
||||||
|
|
||||||
option :analytics_sample_rate do |o|
|
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.type :float
|
||||||
o.lazy
|
o.env "DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE"
|
||||||
|
o.default 1.0
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(Datadog::Tracing::Contrib::SpanAttributeSchema)
|
if defined?(Datadog::Tracing::Contrib::SpanAttributeSchema)
|
||||||
@ -162,7 +165,17 @@ module Datadog::Tracing
|
|||||||
|
|
||||||
option :distributed_tracing, default: true
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -192,7 +205,7 @@ module Datadog::Tracing
|
|||||||
class Integration
|
class Integration
|
||||||
include Contrib::Integration
|
include Contrib::Integration
|
||||||
|
|
||||||
MINIMUM_VERSION = Gem::Version.new("0.10.2")
|
MINIMUM_VERSION = Gem::Version.new("1.0.1")
|
||||||
|
|
||||||
register_as :httpx
|
register_as :httpx
|
||||||
|
|
||||||
|
@ -149,17 +149,29 @@ module HTTPX
|
|||||||
deadline: @options.grpc_deadline,
|
deadline: @options.grpc_deadline,
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
|
local_rpc_name = rpc_name.underscore
|
||||||
|
|
||||||
session_class = Class.new(self.class) do
|
session_class = Class.new(self.class) do
|
||||||
|
# define rpc method with ruby style name
|
||||||
class_eval(<<-OUT, __FILE__, __LINE__ + 1)
|
class_eval(<<-OUT, __FILE__, __LINE__ + 1)
|
||||||
def #{rpc_name}(input, **opts) # def grpc_action(input, **opts)
|
def #{local_rpc_name}(input, **opts) # def grpc_action(input, **opts)
|
||||||
rpc_execute("#{rpc_name}", input, **opts) # rpc_execute("grpc_action", input, **opts)
|
rpc_execute("#{local_rpc_name}", input, **opts) # rpc_execute("grpc_action", input, **opts)
|
||||||
end # end
|
end # end
|
||||||
OUT
|
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
|
end
|
||||||
|
|
||||||
session_class.new(@options.merge(
|
session_class.new(@options.merge(
|
||||||
grpc_rpcs: @options.grpc_rpcs.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
|
).freeze
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
@ -102,7 +102,7 @@ class HTTPXAwsSigv4Test < Minitest::Test
|
|||||||
private
|
private
|
||||||
|
|
||||||
def sigv4_session(**options)
|
def sigv4_session(**options)
|
||||||
HTTPX.plugin(:aws_sigv4).aws_sigv4_authentication(**{ service: "s3", region: "us-east-1", username: "akid",
|
HTTPX.plugin(:aws_sigv4).aws_sigv4_authentication(service: "s3", region: "us-east-1", username: "akid",
|
||||||
password: "secret" }.merge(options))
|
password: "secret", **options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,18 @@ module Requests
|
|||||||
module GRPC
|
module GRPC
|
||||||
include GRPCHelpers
|
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
|
def test_plugin_grpc_unary_plain_bytestreams
|
||||||
no_marshal = proc { |x| x }
|
no_marshal = proc { |x| x }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user