Compare commits

...

7 Commits

Author SHA1 Message Date
HoneyryderChuck
f98b8d9c10 bump version to 0.24.7 2023-10-13 16:53:33 +01:00
HoneyryderChuck
1e9fa3e38c readded support for older datadog versions... 2023-10-13 16:47:15 +01:00
HoneyryderChuck
efcadf7d2b fixing datadog integration, removing support for versions older than 1.13.0 2023-10-13 16:45:12 +01:00
HoneyryderChuck
71dee0c6e7 setting http-2-next last supported version to anything lower than 1.0.0, in order for future changes not to break 2023-10-13 16:13:00 +01:00
HoneyryderChuck
d0182eabab linting updates 2023-10-13 16:11:29 +01:00
Thomas Steinhausen
7fc8d70c53 Fix and enhance rpc method definition
Snake case named procedures could not be called. Now two methods are defined, where one is underscore named and the second has the originla procedure name as called on the service.
2023-10-13 16:11:17 +01:00
Thomas Steinhausen
e942b34a1f Test camel case grpc procedure names
Show that a camel case procedure can be called with underscored name.
2023-10-13 16:10:15 +01:00
7 changed files with 86 additions and 20 deletions

View File

@ -0,0 +1,10 @@
# 0.24.6
## dependencies
`http-2-next` last supported version for the 0.x series is the last version before v1. This shoul ensure that older versions of `httpx` won't be affected by any of the recent breaking changes.
## Bugfixes
* `grpc`: setup of rpc calls from camel-cased symbols has been fixed. As an improvement, the GRPC-enabled session will now support both snake-cased, as well as camel-cased calls.
* `datadog` adapter has now been patched to support the most recent breaking changes of `ddtrace` configuration DSL (`env_to_bool` is no longer supported).

View File

@ -32,5 +32,5 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.add_runtime_dependency "http-2-next", ">= 0.4.1"
gem.add_runtime_dependency "http-2-next", "< 1.0.0"
end

View File

@ -188,19 +188,39 @@ module TRACING_MODULE # rubocop:disable Naming/ClassAndModuleCamelCase
option :distributed_tracing, default: true
option :split_by_domain, default: false
option :enabled do |o|
o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) }
o.lazy
end
if DDTrace::VERSION::STRING >= "1.13.0"
option :enabled do |o|
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
end
option :analytics_enabled do |o|
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
option :analytics_sample_rate do |o|
o.type :float
o.env "DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE"
o.default 1.0
end
else
option :enabled do |o|
o.default { env_to_bool("DD_TRACE_HTTPX_ENABLED", true) }
o.lazy
end
option :analytics_enabled do |o|
o.default { env_to_bool(%w[DD_TRACE_HTTPX_ANALYTICS_ENABLED DD_HTTPX_ANALYTICS_ENABLED], false) }
o.lazy
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
end
end
if defined?(TRACING_MODULE::Contrib::SpanAttributeSchema)
@ -224,7 +244,19 @@ module TRACING_MODULE # rubocop:disable Naming/ClassAndModuleCamelCase
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
elsif DDTrace::VERSION::STRING >= "1.13.0"
option :error_handler do |o|
o.type :proc
o.experimental_default_proc(&DEFAULT_ERROR_HANDLER)
end
else
option :error_handler, default: DEFAULT_ERROR_HANDLER
end
end
end

View File

@ -141,17 +141,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

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module HTTPX
VERSION = "0.24.6"
VERSION = "0.24.7"
end

View File

@ -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

View File

@ -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 }