ddtrace 1.14.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +178 -2
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +3 -5
- data/ext/ddtrace_profiling_native_extension/clock_id.h +0 -3
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +0 -22
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +0 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +41 -6
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +3 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +76 -24
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +207 -32
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.h +1 -1
- data/ext/ddtrace_profiling_native_extension/extconf.rb +8 -2
- data/ext/ddtrace_profiling_native_extension/http_transport.c +26 -10
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.c +42 -0
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +6 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -16
- data/ext/ddtrace_profiling_native_extension/pid_controller.c +57 -0
- data/ext/ddtrace_profiling_native_extension/pid_controller.h +45 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +17 -12
- data/ext/ddtrace_profiling_native_extension/profiling.c +0 -2
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +74 -37
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +13 -3
- data/lib/datadog/appsec/assets/waf_rules/processors.json +92 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +698 -75
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +114 -0
- data/lib/datadog/appsec/assets/waf_rules/strict.json +98 -8
- data/lib/datadog/appsec/assets.rb +8 -0
- data/lib/datadog/appsec/component.rb +9 -2
- data/lib/datadog/appsec/configuration/settings.rb +61 -2
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +8 -6
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +2 -7
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +2 -5
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +2 -5
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +3 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +23 -9
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +3 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +9 -3
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +2 -5
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +6 -4
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +13 -7
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +2 -5
- data/lib/datadog/appsec/event.rb +106 -50
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +2 -5
- data/lib/datadog/appsec/processor/actions.rb +49 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +22 -2
- data/lib/datadog/appsec/processor.rb +34 -6
- data/lib/datadog/appsec/remote.rb +4 -1
- data/lib/datadog/appsec/response.rb +82 -4
- data/lib/datadog/appsec/sample_rate.rb +21 -0
- data/lib/datadog/appsec.rb +2 -2
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +29 -24
- data/lib/datadog/core/configuration/base.rb +1 -11
- data/lib/datadog/core/configuration/components.rb +7 -2
- data/lib/datadog/core/configuration/ext.rb +21 -0
- data/lib/datadog/core/configuration/option.rb +2 -4
- data/lib/datadog/core/configuration/option_definition.rb +17 -41
- data/lib/datadog/core/configuration/options.rb +5 -5
- data/lib/datadog/core/configuration/settings.rb +47 -45
- data/lib/datadog/core/environment/execution.rb +47 -9
- data/lib/datadog/core/environment/variable_helpers.rb +0 -69
- data/lib/datadog/core/error.rb +1 -0
- data/lib/datadog/core/git/ext.rb +2 -0
- data/lib/datadog/core/remote/client/capabilities.rb +1 -1
- data/lib/datadog/core/remote/component.rb +2 -2
- data/lib/datadog/core/remote/negotiation.rb +2 -2
- data/lib/datadog/core/remote/transport/config.rb +60 -0
- data/lib/datadog/core/remote/transport/http/api/instance.rb +39 -0
- data/lib/datadog/core/remote/transport/http/api/spec.rb +21 -0
- data/lib/datadog/core/remote/transport/http/api.rb +58 -0
- data/lib/datadog/core/remote/transport/http/builder.rb +219 -0
- data/lib/datadog/core/remote/transport/http/client.rb +48 -0
- data/lib/datadog/core/remote/transport/http/config.rb +280 -0
- data/lib/datadog/core/remote/transport/http/negotiation.rb +146 -0
- data/lib/datadog/core/remote/transport/http.rb +179 -0
- data/lib/datadog/core/{transport → remote/transport}/negotiation.rb +25 -23
- data/lib/datadog/core/telemetry/collector.rb +3 -2
- data/lib/datadog/core/telemetry/http/transport.rb +2 -1
- data/lib/datadog/core/transport/ext.rb +47 -0
- data/lib/datadog/core/transport/http/adapters/net.rb +168 -0
- data/lib/datadog/core/transport/http/adapters/registry.rb +29 -0
- data/lib/datadog/core/transport/http/adapters/test.rb +89 -0
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +83 -0
- data/lib/datadog/core/transport/http/api/endpoint.rb +31 -0
- data/lib/datadog/core/transport/http/api/fallbacks.rb +26 -0
- data/lib/datadog/core/transport/http/api/map.rb +18 -0
- data/lib/datadog/core/transport/http/env.rb +62 -0
- data/lib/datadog/core/transport/http/response.rb +60 -0
- data/lib/datadog/core/transport/parcel.rb +22 -0
- data/lib/datadog/core/transport/request.rb +17 -0
- data/lib/datadog/core/transport/response.rb +64 -0
- data/lib/datadog/core/workers/polling.rb +2 -2
- data/lib/datadog/opentelemetry/api/context.rb +10 -3
- data/lib/datadog/opentelemetry/sdk/propagator.rb +2 -1
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +14 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +68 -0
- data/lib/datadog/opentelemetry/trace.rb +58 -0
- data/lib/datadog/opentelemetry.rb +1 -0
- data/lib/datadog/opentracer.rb +9 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +12 -18
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/thread_context.rb +9 -1
- data/lib/datadog/profiling/component.rb +24 -99
- data/lib/datadog/profiling/ext.rb +0 -12
- data/lib/datadog/profiling/flush.rb +0 -3
- data/lib/datadog/profiling/http_transport.rb +6 -3
- data/lib/datadog/profiling/native_extension.rb +0 -21
- data/lib/datadog/profiling/profiler.rb +11 -12
- data/lib/datadog/profiling.rb +8 -81
- data/lib/datadog/tracing/component.rb +10 -4
- data/lib/datadog/tracing/configuration/agent_settings_resolver.rb +13 -0
- data/lib/datadog/tracing/configuration/ext.rb +4 -2
- data/lib/datadog/tracing/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +104 -197
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +3 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +7 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +6 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +7 -0
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +9 -2
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +5 -0
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +5 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +8 -0
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -0
- data/lib/datadog/tracing/contrib/ext.rb +3 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +21 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +11 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +18 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +0 -4
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +3 -3
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +7 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +13 -3
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +2 -2
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +7 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +1 -1
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/event.rb +5 -0
- data/lib/datadog/tracing/contrib/rack/header_tagging.rb +14 -4
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +4 -4
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/tags.rb +5 -0
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -0
- data/lib/datadog/tracing/contrib/sequel/utils.rb +5 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
- data/lib/datadog/tracing/distributed/propagation.rb +13 -33
- data/lib/datadog/tracing/metadata/tagging.rb +3 -3
- data/lib/datadog/tracing/sync_writer.rb +3 -3
- data/lib/datadog/tracing/tracer.rb +2 -0
- data/lib/datadog/{core → tracing}/transport/http/api/instance.rb +1 -1
- data/lib/datadog/{core → tracing}/transport/http/api/spec.rb +1 -1
- data/lib/datadog/tracing/transport/http/api.rb +43 -0
- data/lib/datadog/{core → tracing}/transport/http/builder.rb +13 -68
- data/lib/datadog/tracing/transport/http/client.rb +57 -0
- data/lib/datadog/tracing/transport/http/statistics.rb +47 -0
- data/lib/datadog/tracing/transport/http/traces.rb +152 -0
- data/lib/datadog/tracing/transport/http.rb +124 -0
- data/lib/datadog/tracing/transport/io/client.rb +89 -0
- data/lib/datadog/tracing/transport/io/response.rb +27 -0
- data/lib/datadog/tracing/transport/io/traces.rb +101 -0
- data/lib/datadog/tracing/transport/io.rb +30 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +126 -0
- data/lib/datadog/tracing/transport/statistics.rb +77 -0
- data/lib/datadog/tracing/transport/trace_formatter.rb +209 -0
- data/lib/datadog/tracing/transport/traces.rb +224 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +5 -3
- data/lib/datadog/tracing/workers.rb +3 -2
- data/lib/datadog/tracing/writer.rb +5 -2
- data/lib/ddtrace/transport/ext.rb +17 -15
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace.rb +1 -1
- metadata +72 -96
- data/lib/datadog/ci/configuration/components.rb +0 -32
- data/lib/datadog/ci/configuration/settings.rb +0 -51
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/cucumber/ext.rb +0 -22
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +0 -94
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +0 -28
- data/lib/datadog/ci/contrib/cucumber/integration.rb +0 -47
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +0 -27
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/minitest/ext.rb +0 -21
- data/lib/datadog/ci/contrib/minitest/integration.rb +0 -49
- data/lib/datadog/ci/contrib/minitest/patcher.rb +0 -27
- data/lib/datadog/ci/contrib/minitest/test_helper.rb +0 -68
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/rspec/example.rb +0 -68
- data/lib/datadog/ci/contrib/rspec/ext.rb +0 -21
- data/lib/datadog/ci/contrib/rspec/integration.rb +0 -48
- data/lib/datadog/ci/contrib/rspec/patcher.rb +0 -27
- data/lib/datadog/ci/ext/app_types.rb +0 -9
- data/lib/datadog/ci/ext/environment.rb +0 -575
- data/lib/datadog/ci/ext/settings.rb +0 -10
- data/lib/datadog/ci/ext/test.rb +0 -35
- data/lib/datadog/ci/extensions.rb +0 -19
- data/lib/datadog/ci/flush.rb +0 -38
- data/lib/datadog/ci/test.rb +0 -81
- data/lib/datadog/ci.rb +0 -21
- data/lib/datadog/core/configuration/dependency_resolver.rb +0 -28
- data/lib/datadog/core/configuration/option_definition_set.rb +0 -22
- data/lib/datadog/core/configuration/option_set.rb +0 -10
- data/lib/datadog/core/transport/config.rb +0 -58
- data/lib/datadog/core/transport/http/api.rb +0 -57
- data/lib/datadog/core/transport/http/client.rb +0 -45
- data/lib/datadog/core/transport/http/config.rb +0 -278
- data/lib/datadog/core/transport/http/negotiation.rb +0 -144
- data/lib/datadog/core/transport/http.rb +0 -169
- data/lib/datadog/core/utils/object_set.rb +0 -43
- data/lib/datadog/core/utils/string_table.rb +0 -47
- data/lib/datadog/profiling/backtrace_location.rb +0 -34
- data/lib/datadog/profiling/buffer.rb +0 -43
- data/lib/datadog/profiling/collectors/old_stack.rb +0 -301
- data/lib/datadog/profiling/encoding/profile.rb +0 -41
- data/lib/datadog/profiling/event.rb +0 -15
- data/lib/datadog/profiling/events/stack.rb +0 -82
- data/lib/datadog/profiling/old_recorder.rb +0 -107
- data/lib/datadog/profiling/pprof/builder.rb +0 -125
- data/lib/datadog/profiling/pprof/converter.rb +0 -102
- data/lib/datadog/profiling/pprof/message_set.rb +0 -16
- data/lib/datadog/profiling/pprof/payload.rb +0 -20
- data/lib/datadog/profiling/pprof/pprof.proto +0 -212
- data/lib/datadog/profiling/pprof/pprof_pb.rb +0 -81
- data/lib/datadog/profiling/pprof/stack_sample.rb +0 -139
- data/lib/datadog/profiling/pprof/string_table.rb +0 -12
- data/lib/datadog/profiling/pprof/template.rb +0 -118
- data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +0 -43
- data/lib/datadog/profiling/trace_identifiers/helper.rb +0 -45
- data/lib/ddtrace/transport/http/adapters/net.rb +0 -168
- data/lib/ddtrace/transport/http/adapters/registry.rb +0 -27
- data/lib/ddtrace/transport/http/adapters/test.rb +0 -85
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +0 -77
- data/lib/ddtrace/transport/http/api/endpoint.rb +0 -29
- data/lib/ddtrace/transport/http/api/fallbacks.rb +0 -24
- data/lib/ddtrace/transport/http/api/instance.rb +0 -35
- data/lib/ddtrace/transport/http/api/map.rb +0 -16
- data/lib/ddtrace/transport/http/api/spec.rb +0 -17
- data/lib/ddtrace/transport/http/api.rb +0 -39
- data/lib/ddtrace/transport/http/builder.rb +0 -176
- data/lib/ddtrace/transport/http/client.rb +0 -52
- data/lib/ddtrace/transport/http/env.rb +0 -58
- data/lib/ddtrace/transport/http/response.rb +0 -58
- data/lib/ddtrace/transport/http/statistics.rb +0 -43
- data/lib/ddtrace/transport/http/traces.rb +0 -144
- data/lib/ddtrace/transport/http.rb +0 -117
- data/lib/ddtrace/transport/io/client.rb +0 -85
- data/lib/ddtrace/transport/io/response.rb +0 -25
- data/lib/ddtrace/transport/io/traces.rb +0 -99
- data/lib/ddtrace/transport/io.rb +0 -28
- data/lib/ddtrace/transport/parcel.rb +0 -20
- data/lib/ddtrace/transport/request.rb +0 -15
- data/lib/ddtrace/transport/response.rb +0 -60
- data/lib/ddtrace/transport/serializable_trace.rb +0 -122
- data/lib/ddtrace/transport/statistics.rb +0 -75
- data/lib/ddtrace/transport/trace_formatter.rb +0 -207
- data/lib/ddtrace/transport/traces.rb +0 -216
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require_relative '../negotiation'
|
6
|
+
require_relative 'client'
|
7
|
+
require_relative '../../../transport/http/response'
|
8
|
+
require_relative '../../../transport/http/api/endpoint'
|
9
|
+
|
10
|
+
# TODO: Decouple standard transport/http/api/instance
|
11
|
+
#
|
12
|
+
# Separate classes are needed because transport/http/trace includes
|
13
|
+
# Trace::API::Instance which closes over and uses a single spec, which is
|
14
|
+
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
|
15
|
+
# need an independent toplevel path at the endpoint level.
|
16
|
+
#
|
17
|
+
# Separate classes are needed because of `include Trace::API::Instance`.
|
18
|
+
#
|
19
|
+
# Below should be:
|
20
|
+
# require_relative '../../../../ddtrace/transport/http/api/instance'
|
21
|
+
require_relative 'api/instance'
|
22
|
+
# Below should be:
|
23
|
+
# require_relative '../../../../ddtrace/transport/http/api/spec'
|
24
|
+
require_relative 'api/spec'
|
25
|
+
|
26
|
+
module Datadog
|
27
|
+
module Core
|
28
|
+
module Remote
|
29
|
+
module Transport
|
30
|
+
module HTTP
|
31
|
+
# HTTP transport behavior for agent feature negotiation
|
32
|
+
module Negotiation
|
33
|
+
# Response from HTTP transport for agent feature negotiation
|
34
|
+
class Response
|
35
|
+
include Datadog::Core::Transport::HTTP::Response
|
36
|
+
include Core::Remote::Transport::Negotiation::Response
|
37
|
+
|
38
|
+
def initialize(http_response, options = {})
|
39
|
+
super(http_response)
|
40
|
+
|
41
|
+
# TODO: transform endpoint hash in a better object for negotiation
|
42
|
+
# TODO: transform config in a better object, notably config has max_request_bytes
|
43
|
+
@version = options[:version]
|
44
|
+
@endpoints = options[:endpoints]
|
45
|
+
@config = options[:config]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Extensions for HTTP client
|
50
|
+
module Client
|
51
|
+
def send_info_payload(request)
|
52
|
+
send_request(request) do |api, env|
|
53
|
+
api.send_info(env)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
module API
|
59
|
+
# Extensions for HTTP API Spec
|
60
|
+
module Spec
|
61
|
+
attr_reader :info
|
62
|
+
|
63
|
+
def info=(endpoint)
|
64
|
+
@info = endpoint
|
65
|
+
end
|
66
|
+
|
67
|
+
def send_info(env, &block)
|
68
|
+
raise NoNegotiationEndpointDefinedError, self if info.nil?
|
69
|
+
|
70
|
+
info.call(env, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Raised when traces sent but no traces endpoint is defined
|
74
|
+
class NoNegotiationEndpointDefinedError < StandardError
|
75
|
+
attr_reader :spec
|
76
|
+
|
77
|
+
def initialize(spec)
|
78
|
+
super()
|
79
|
+
|
80
|
+
@spec = spec
|
81
|
+
end
|
82
|
+
|
83
|
+
def message
|
84
|
+
'No info endpoint is defined for API specification!'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Extensions for HTTP API Instance
|
90
|
+
module Instance
|
91
|
+
def send_info(env)
|
92
|
+
raise NegotiationNotSupportedError, spec unless spec.is_a?(Negotiation::API::Spec)
|
93
|
+
|
94
|
+
spec.send_info(env) do |request_env|
|
95
|
+
call(request_env)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Raised when traces sent to API that does not support traces
|
100
|
+
class NegotiationNotSupportedError < StandardError
|
101
|
+
attr_reader :spec
|
102
|
+
|
103
|
+
def initialize(spec)
|
104
|
+
super()
|
105
|
+
|
106
|
+
@spec = spec
|
107
|
+
end
|
108
|
+
|
109
|
+
def message
|
110
|
+
'Info not supported for this API!'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Endpoint for negotiation
|
116
|
+
class Endpoint < Datadog::Core::Transport::HTTP::API::Endpoint
|
117
|
+
def initialize(path)
|
118
|
+
super(:get, path)
|
119
|
+
end
|
120
|
+
|
121
|
+
def call(env, &block)
|
122
|
+
# Query for response
|
123
|
+
http_response = super(env, &block)
|
124
|
+
|
125
|
+
# Process the response
|
126
|
+
body = JSON.parse(http_response.payload, symbolize_names: true) if http_response.ok?
|
127
|
+
|
128
|
+
# TODO: there should be more processing here to ensure a proper response_options
|
129
|
+
response_options = body.is_a?(Hash) ? body : {}
|
130
|
+
|
131
|
+
# Build and return a trace response
|
132
|
+
Negotiation::Response.new(http_response, response_options)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Add negotiation behavior to transport components
|
138
|
+
HTTP::Client.include(Negotiation::Client)
|
139
|
+
HTTP::API::Spec.include(Negotiation::API::Spec)
|
140
|
+
HTTP::API::Instance.include(Negotiation::API::Instance)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
require_relative '../../environment/container'
|
6
|
+
require_relative '../../environment/ext'
|
7
|
+
require_relative '../../transport/ext'
|
8
|
+
require_relative '../../transport/http/adapters/net'
|
9
|
+
require_relative '../../transport/http/adapters/unix_socket'
|
10
|
+
require_relative '../../transport/http/adapters/test'
|
11
|
+
|
12
|
+
# TODO: Improve negotiation to allow per endpoint selection
|
13
|
+
#
|
14
|
+
# Since endpoint negotiation happens at the `API::Spec` level there can not be
|
15
|
+
# a mix of endpoints at various versions or versionless without describing all
|
16
|
+
# the possible combinations as specs. See http/api.
|
17
|
+
#
|
18
|
+
# Below should be:
|
19
|
+
# require_relative '../../transport/http/api'
|
20
|
+
require_relative 'http/api'
|
21
|
+
|
22
|
+
# TODO: Decouple transport/http/builder
|
23
|
+
#
|
24
|
+
# See http/builder
|
25
|
+
#
|
26
|
+
# Below should be:
|
27
|
+
# require_relative '../../transport/http/builder'
|
28
|
+
require_relative 'http/builder'
|
29
|
+
|
30
|
+
# TODO: Decouple transport/http
|
31
|
+
#
|
32
|
+
# Because a new transport is required for every (API, Client, Transport)
|
33
|
+
# triplet and endpoints cannot be negotiated independently, there can not be a
|
34
|
+
# single `default` transport, but only endpoint-specific ones.
|
35
|
+
|
36
|
+
module Datadog
|
37
|
+
module Core
|
38
|
+
module Remote
|
39
|
+
module Transport
|
40
|
+
# Namespace for HTTP transport components
|
41
|
+
module HTTP
|
42
|
+
# NOTE: Due to... legacy reasons... This class likes having a default `AgentSettings` instance to fall back to.
|
43
|
+
# Because we generate this instance with an empty instance of `Settings`, the resulting `AgentSettings` below
|
44
|
+
# represents only settings specified via environment variables + the usual defaults.
|
45
|
+
#
|
46
|
+
# DO NOT USE THIS IN NEW CODE, as it ignores any settings specified by users via `Datadog.configure`.
|
47
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS = Datadog::Core::Configuration::AgentSettingsResolver.call(
|
48
|
+
Datadog::Core::Configuration::Settings.new,
|
49
|
+
logger: nil,
|
50
|
+
)
|
51
|
+
|
52
|
+
module_function
|
53
|
+
|
54
|
+
# Builds a new Transport::HTTP::Client
|
55
|
+
def new(klass, &block)
|
56
|
+
Builder.new(&block).to_transport(klass)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Builds a new Transport::HTTP::Client with default settings
|
60
|
+
# Pass a block to override any settings.
|
61
|
+
def root(
|
62
|
+
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
63
|
+
**options
|
64
|
+
)
|
65
|
+
new(Core::Remote::Transport::Negotiation::Transport) do |transport|
|
66
|
+
transport.adapter(agent_settings)
|
67
|
+
transport.headers(default_headers)
|
68
|
+
|
69
|
+
apis = API.defaults
|
70
|
+
|
71
|
+
transport.api API::ROOT, apis[API::ROOT]
|
72
|
+
|
73
|
+
# Apply any settings given by options
|
74
|
+
unless options.empty?
|
75
|
+
transport.default_api = options[:api_version] if options.key?(:api_version)
|
76
|
+
transport.headers options[:headers] if options.key?(:headers)
|
77
|
+
end
|
78
|
+
|
79
|
+
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
80
|
+
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Call block to apply any customization, if provided
|
84
|
+
yield(transport) if block_given?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Builds a new Transport::HTTP::Client with default settings
|
89
|
+
# Pass a block to override any settings.
|
90
|
+
def v7(
|
91
|
+
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
92
|
+
**options
|
93
|
+
)
|
94
|
+
new(Core::Remote::Transport::Config::Transport) do |transport|
|
95
|
+
transport.adapter(agent_settings)
|
96
|
+
transport.headers default_headers
|
97
|
+
|
98
|
+
apis = API.defaults
|
99
|
+
|
100
|
+
transport.api API::V7, apis[API::V7]
|
101
|
+
|
102
|
+
# Apply any settings given by options
|
103
|
+
unless options.empty?
|
104
|
+
transport.default_api = options[:api_version] if options.key?(:api_version)
|
105
|
+
transport.headers options[:headers] if options.key?(:headers)
|
106
|
+
end
|
107
|
+
|
108
|
+
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
109
|
+
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Call block to apply any customization, if provided
|
113
|
+
yield(transport) if block_given?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def default_headers
|
118
|
+
{
|
119
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_TOP_LEVEL => '1',
|
120
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG => Datadog::Core::Environment::Ext::LANG,
|
121
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG_VERSION =>
|
122
|
+
Datadog::Core::Environment::Ext::LANG_VERSION,
|
123
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG_INTERPRETER =>
|
124
|
+
Datadog::Core::Environment::Ext::LANG_INTERPRETER,
|
125
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION =>
|
126
|
+
Datadog::Core::Environment::Ext::TRACER_VERSION
|
127
|
+
}.tap do |headers|
|
128
|
+
# Add container ID, if present.
|
129
|
+
container_id = Datadog::Core::Environment::Container.container_id
|
130
|
+
headers[Datadog::Core::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id unless container_id.nil?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def default_adapter
|
135
|
+
Datadog::Core::Transport::Ext::HTTP::ADAPTER
|
136
|
+
end
|
137
|
+
|
138
|
+
def default_hostname(logger: Datadog.logger)
|
139
|
+
logger.warn(
|
140
|
+
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
141
|
+
'be removed on a future ddtrace release.'
|
142
|
+
)
|
143
|
+
|
144
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.hostname
|
145
|
+
end
|
146
|
+
|
147
|
+
def default_port(logger: Datadog.logger)
|
148
|
+
logger.warn(
|
149
|
+
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
150
|
+
'be removed on a future ddtrace release.'
|
151
|
+
)
|
152
|
+
|
153
|
+
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.port
|
154
|
+
end
|
155
|
+
|
156
|
+
def default_url(logger: Datadog.logger)
|
157
|
+
logger.warn(
|
158
|
+
'Deprecated for removal: Using #default_url for configuration is deprecated and will ' \
|
159
|
+
'be removed on a future ddtrace release.'
|
160
|
+
)
|
161
|
+
|
162
|
+
nil
|
163
|
+
end
|
164
|
+
|
165
|
+
# Add adapters to registry
|
166
|
+
Builder::REGISTRY.set(Datadog::Core::Transport::HTTP::Adapters::Net, Datadog::Core::Transport::Ext::HTTP::ADAPTER)
|
167
|
+
Builder::REGISTRY.set(
|
168
|
+
Datadog::Core::Transport::HTTP::Adapters::Test,
|
169
|
+
Datadog::Core::Transport::Ext::Test::ADAPTER
|
170
|
+
)
|
171
|
+
Builder::REGISTRY.set(
|
172
|
+
Datadog::Core::Transport::HTTP::Adapters::UnixSocket,
|
173
|
+
Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
|
174
|
+
)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../../
|
3
|
+
require_relative '../../../core/transport/request'
|
4
4
|
|
5
5
|
# TODO: Resolve conceptual conundrum
|
6
6
|
#
|
@@ -23,35 +23,37 @@ require_relative '../../../ddtrace/transport/request'
|
|
23
23
|
|
24
24
|
module Datadog
|
25
25
|
module Core
|
26
|
-
module
|
27
|
-
module
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
module Remote
|
27
|
+
module Transport
|
28
|
+
module Negotiation
|
29
|
+
# Negotiation request
|
30
|
+
class Request < Datadog::Core::Transport::Request
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
# Negotiation response
|
34
|
+
module Response
|
35
|
+
attr_reader :version, :endpoints, :config
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
# Negotiation transport
|
39
|
+
class Transport
|
40
|
+
attr_reader :client, :apis, :default_api, :current_api_id
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
def initialize(apis, default_api)
|
43
|
+
@apis = apis
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
@client = HTTP::Client.new(current_api)
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
def send_info
|
49
|
+
request = Request.new
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
@client.send_info_payload(request)
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
def current_api
|
55
|
+
@apis[HTTP::API::ROOT]
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -11,7 +11,7 @@ require_relative 'v1/dependency'
|
|
11
11
|
require_relative 'v1/host'
|
12
12
|
require_relative 'v1/integration'
|
13
13
|
require_relative 'v1/product'
|
14
|
-
require_relative '
|
14
|
+
require_relative '../transport/ext'
|
15
15
|
|
16
16
|
module Datadog
|
17
17
|
module Core
|
@@ -146,6 +146,7 @@ module Datadog
|
|
146
146
|
options['logger.instance'] = configuration.logger.instance.class.to_s
|
147
147
|
options['appsec.enabled'] = configuration.dig('appsec', 'enabled') if configuration.respond_to?('appsec')
|
148
148
|
options['tracing.opentelemetry.enabled'] = !defined?(Datadog::OpenTelemetry::LOADED).nil?
|
149
|
+
options['tracing.opentracing.enabled'] = !defined?(Datadog::OpenTracer::LOADED).nil?
|
149
150
|
options.compact!
|
150
151
|
options
|
151
152
|
end
|
@@ -190,7 +191,7 @@ module Datadog
|
|
190
191
|
|
191
192
|
def agent_transport
|
192
193
|
adapter = Core::Configuration::AgentSettingsResolver.call(Datadog.configuration).adapter
|
193
|
-
if adapter == Datadog::Transport::Ext::UnixSocket::ADAPTER
|
194
|
+
if adapter == Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
|
194
195
|
'UDS'
|
195
196
|
else
|
196
197
|
'TCP'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../configuration/settings'
|
4
|
+
require_relative '../../transport/ext'
|
4
5
|
require_relative 'env'
|
5
6
|
require_relative 'ext'
|
6
7
|
require_relative 'adapters/net'
|
@@ -38,7 +39,7 @@ module Datadog
|
|
38
39
|
|
39
40
|
def headers(request_type:, api_version: Http::Ext::API_VERSION)
|
40
41
|
{
|
41
|
-
Datadog::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST => '1',
|
42
|
+
Datadog::Core::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST => '1',
|
42
43
|
Http::Ext::HEADER_CONTENT_TYPE => Http::Ext::CONTENT_TYPE_APPLICATION_JSON,
|
43
44
|
Http::Ext::HEADER_DD_TELEMETRY_API_VERSION => api_version,
|
44
45
|
Http::Ext::HEADER_DD_TELEMETRY_REQUEST_TYPE => request_type,
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../configuration/ext'
|
4
|
+
# DEV(2.0): This file should replace /ddtrace/transport/ext.rb
|
5
|
+
# WARN: This file is used in /dd trace/transport/ext.rb which is a public API. Any changes here
|
6
|
+
# should be treated as changes to a public API.
|
7
|
+
module Datadog
|
8
|
+
module Core
|
9
|
+
module Transport
|
10
|
+
module Ext
|
11
|
+
module HTTP
|
12
|
+
ADAPTER = Datadog::Core::Configuration::Ext::Agent::HTTP::ADAPTER
|
13
|
+
DEFAULT_HOST = Datadog::Core::Configuration::Ext::Agent::HTTP::DEFAULT_HOST
|
14
|
+
DEFAULT_PORT = Datadog::Core::Configuration::Ext::Agent::HTTP::DEFAULT_PORT
|
15
|
+
|
16
|
+
HEADER_CONTAINER_ID = 'Datadog-Container-ID'
|
17
|
+
HEADER_DD_API_KEY = 'DD-API-KEY'
|
18
|
+
# Tells agent that `_dd.top_level` metrics have been set by the tracer.
|
19
|
+
# The agent will not calculate top-level spans but instead trust the tracer tagging.
|
20
|
+
#
|
21
|
+
# This prevents partially flushed traces being mistakenly marked as top-level.
|
22
|
+
#
|
23
|
+
# Setting this header to any non-empty value enables this feature.
|
24
|
+
HEADER_CLIENT_COMPUTED_TOP_LEVEL = 'Datadog-Client-Computed-Top-Level'
|
25
|
+
HEADER_META_LANG = 'Datadog-Meta-Lang'
|
26
|
+
HEADER_META_LANG_VERSION = 'Datadog-Meta-Lang-Version'
|
27
|
+
HEADER_META_LANG_INTERPRETER = 'Datadog-Meta-Lang-Interpreter'
|
28
|
+
HEADER_META_TRACER_VERSION = 'Datadog-Meta-Tracer-Version'
|
29
|
+
|
30
|
+
# Header that prevents the Net::HTTP integration from tracing internal trace requests.
|
31
|
+
# Set it to any value to skip tracing.
|
32
|
+
HEADER_DD_INTERNAL_UNTRACED_REQUEST = 'DD-Internal-Untraced-Request'
|
33
|
+
end
|
34
|
+
|
35
|
+
module Test
|
36
|
+
ADAPTER = :test
|
37
|
+
end
|
38
|
+
|
39
|
+
module UnixSocket
|
40
|
+
ADAPTER = Datadog::Core::Configuration::Ext::Agent::UnixSocket::ADAPTER
|
41
|
+
DEFAULT_PATH = Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_PATH
|
42
|
+
DEFAULT_TIMEOUT_SECONDS = Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_TIMEOUT_SECONDS
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../core/transport/response'
|
4
|
+
require_relative '../../../../core/vendor/multipart-post/net/http/post/multipart'
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module Core
|
8
|
+
module Transport
|
9
|
+
module HTTP
|
10
|
+
module Adapters
|
11
|
+
# Adapter for Net::HTTP
|
12
|
+
class Net
|
13
|
+
attr_reader \
|
14
|
+
:hostname,
|
15
|
+
:port,
|
16
|
+
:timeout,
|
17
|
+
:ssl
|
18
|
+
|
19
|
+
# in seconds
|
20
|
+
DEFAULT_TIMEOUT = 30
|
21
|
+
|
22
|
+
# @deprecated Positional parameters are deprecated. Use named parameters instead.
|
23
|
+
def initialize(hostname = nil, port = nil, **options)
|
24
|
+
@hostname = hostname || options.fetch(:hostname)
|
25
|
+
@port = port || options.fetch(:port)
|
26
|
+
@timeout = options[:timeout] || DEFAULT_TIMEOUT
|
27
|
+
@ssl = options.key?(:ssl) ? options[:ssl] == true : false
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.build(agent_settings)
|
31
|
+
new(
|
32
|
+
hostname: agent_settings.hostname,
|
33
|
+
port: agent_settings.port,
|
34
|
+
timeout: agent_settings.timeout_seconds,
|
35
|
+
ssl: agent_settings.ssl
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def open(&block)
|
40
|
+
# DEV Initializing +Net::HTTP+ directly help us avoid expensive
|
41
|
+
# options processing done in +Net::HTTP.start+:
|
42
|
+
# https://github.com/ruby/ruby/blob/b2d96abb42abbe2e01f010ffc9ac51f0f9a50002/lib/net/http.rb#L614-L618
|
43
|
+
req = ::Net::HTTP.new(hostname, port, nil)
|
44
|
+
|
45
|
+
req.use_ssl = ssl
|
46
|
+
req.open_timeout = req.read_timeout = timeout
|
47
|
+
|
48
|
+
req.start(&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def call(env)
|
52
|
+
if respond_to?(env.verb)
|
53
|
+
send(env.verb, env)
|
54
|
+
else
|
55
|
+
raise UnknownHTTPMethod, env
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def get(env)
|
60
|
+
get = ::Net::HTTP::Get.new(env.path, env.headers)
|
61
|
+
|
62
|
+
# Connect and send the request
|
63
|
+
http_response = open do |http|
|
64
|
+
http.request(get)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Build and return response
|
68
|
+
Response.new(http_response)
|
69
|
+
end
|
70
|
+
|
71
|
+
def post(env)
|
72
|
+
post = nil
|
73
|
+
|
74
|
+
if env.form.nil? || env.form.empty?
|
75
|
+
post = ::Net::HTTP::Post.new(env.path, env.headers)
|
76
|
+
post.body = env.body
|
77
|
+
else
|
78
|
+
post = ::Datadog::Core::Vendor::Net::HTTP::Post::Multipart.new(
|
79
|
+
env.path,
|
80
|
+
env.form,
|
81
|
+
env.headers
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Connect and send the request
|
86
|
+
http_response = open do |http|
|
87
|
+
http.request(post)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Build and return response
|
91
|
+
Response.new(http_response)
|
92
|
+
end
|
93
|
+
|
94
|
+
def url
|
95
|
+
"http://#{hostname}:#{port}?timeout=#{timeout}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Raised when called with an unknown HTTP method
|
99
|
+
class UnknownHTTPMethod < StandardError
|
100
|
+
attr_reader :verb
|
101
|
+
|
102
|
+
def initialize(verb)
|
103
|
+
super("No matching Net::HTTP function for '#{verb}'!")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# A wrapped Net::HTTP response that implements the Transport::Response interface
|
108
|
+
class Response
|
109
|
+
include Datadog::Core::Transport::Response
|
110
|
+
|
111
|
+
attr_reader :http_response
|
112
|
+
|
113
|
+
def initialize(http_response)
|
114
|
+
@http_response = http_response
|
115
|
+
end
|
116
|
+
|
117
|
+
def payload
|
118
|
+
return super if http_response.nil?
|
119
|
+
|
120
|
+
http_response.body
|
121
|
+
end
|
122
|
+
|
123
|
+
def code
|
124
|
+
return super if http_response.nil?
|
125
|
+
|
126
|
+
http_response.code.to_i
|
127
|
+
end
|
128
|
+
|
129
|
+
def ok?
|
130
|
+
return super if http_response.nil?
|
131
|
+
|
132
|
+
code.between?(200, 299)
|
133
|
+
end
|
134
|
+
|
135
|
+
def unsupported?
|
136
|
+
return super if http_response.nil?
|
137
|
+
|
138
|
+
code == 415
|
139
|
+
end
|
140
|
+
|
141
|
+
def not_found?
|
142
|
+
return super if http_response.nil?
|
143
|
+
|
144
|
+
code == 404
|
145
|
+
end
|
146
|
+
|
147
|
+
def client_error?
|
148
|
+
return super if http_response.nil?
|
149
|
+
|
150
|
+
code.between?(400, 499)
|
151
|
+
end
|
152
|
+
|
153
|
+
def server_error?
|
154
|
+
return super if http_response.nil?
|
155
|
+
|
156
|
+
code.between?(500, 599)
|
157
|
+
end
|
158
|
+
|
159
|
+
def inspect
|
160
|
+
"#{super}, http_response:#{http_response}"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Core
|
5
|
+
module Transport
|
6
|
+
module HTTP
|
7
|
+
module Adapters
|
8
|
+
# List of available adapters
|
9
|
+
class Registry
|
10
|
+
def initialize
|
11
|
+
@adapters = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(name)
|
15
|
+
@adapters[name]
|
16
|
+
end
|
17
|
+
|
18
|
+
def set(klass, name = nil)
|
19
|
+
name ||= klass.to_s
|
20
|
+
return if name.nil?
|
21
|
+
|
22
|
+
@adapters[name] = klass
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|