Module: Datadog::Core::Remote::Transport::HTTP
- Defined in:
- lib/datadog/core/remote/transport/http.rb,
lib/datadog/core/remote/transport/http/api.rb,
lib/datadog/core/remote/transport/http/client.rb,
lib/datadog/core/remote/transport/http/config.rb,
lib/datadog/core/remote/transport/http/builder.rb,
lib/datadog/core/remote/transport/http/api/spec.rb,
lib/datadog/core/remote/transport/http/negotiation.rb,
lib/datadog/core/remote/transport/http/api/instance.rb
Overview
Namespace for HTTP transport components
Defined Under Namespace
Modules: API, Config, Negotiation Classes: Builder, Client
Constant Summary collapse
- DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS =
NOTE: Due to… legacy reasons… This class likes having a default ‘AgentSettings` instance to fall back to. Because we generate this instance with an empty instance of `Settings`, the resulting `AgentSettings` below represents only settings specified via environment variables + the usual defaults.
DO NOT USE THIS IN NEW CODE, as it ignores any settings specified by users via ‘Datadog.configure`.
Datadog::Core::Configuration::AgentSettingsResolver.call( Datadog::Core::Configuration::Settings.new, logger: nil, )
Class Method Summary collapse
- .default_adapter ⇒ Object
- .default_headers ⇒ Object
- .default_hostname(logger: Datadog.logger) ⇒ Object
- .default_port(logger: Datadog.logger) ⇒ Object
- .default_url(logger: Datadog.logger) ⇒ Object
-
.new(klass, &block) ⇒ Object
Builds a new Transport::HTTP::Client.
-
.root(agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, **options) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
-
.v7(agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, **options) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
Class Method Details
.default_adapter ⇒ Object
134 135 136 |
# File 'lib/datadog/core/remote/transport/http.rb', line 134 def default_adapter Datadog::Core::Transport::Ext::HTTP::ADAPTER end |
.default_headers ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/datadog/core/remote/transport/http.rb', line 117 def default_headers { Datadog::Core::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_TOP_LEVEL => '1', Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG => Datadog::Core::Environment::Ext::LANG, Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG_VERSION => Datadog::Core::Environment::Ext::LANG_VERSION, Datadog::Core::Transport::Ext::HTTP::HEADER_META_LANG_INTERPRETER => Datadog::Core::Environment::Ext::LANG_INTERPRETER, Datadog::Core::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION => Datadog::Core::Environment::Ext::TRACER_VERSION }.tap do |headers| # Add container ID, if present. container_id = Datadog::Core::Environment::Container.container_id headers[Datadog::Core::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id unless container_id.nil? end end |
.default_hostname(logger: Datadog.logger) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/datadog/core/remote/transport/http.rb', line 138 def default_hostname(logger: Datadog.logger) logger.warn( 'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \ 'be removed on a future ddtrace release.' ) DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.hostname end |
.default_port(logger: Datadog.logger) ⇒ Object
147 148 149 150 151 152 153 154 |
# File 'lib/datadog/core/remote/transport/http.rb', line 147 def default_port(logger: Datadog.logger) logger.warn( 'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \ 'be removed on a future ddtrace release.' ) DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.port end |
.default_url(logger: Datadog.logger) ⇒ Object
156 157 158 159 160 161 162 163 |
# File 'lib/datadog/core/remote/transport/http.rb', line 156 def default_url(logger: Datadog.logger) logger.warn( 'Deprecated for removal: Using #default_url for configuration is deprecated and will ' \ 'be removed on a future ddtrace release.' ) nil end |
.new(klass, &block) ⇒ Object
Builds a new Transport::HTTP::Client
55 56 57 |
# File 'lib/datadog/core/remote/transport/http.rb', line 55 def new(klass, &block) Builder.new(&block).to_transport(klass) end |
.root(agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, **options) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/datadog/core/remote/transport/http.rb', line 61 def root( agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, ** ) new(Core::Remote::Transport::Negotiation::Transport) do |transport| transport.adapter(agent_settings) transport.headers(default_headers) apis = API.defaults transport.api API::ROOT, apis[API::ROOT] # Apply any settings given by options unless .empty? transport.default_api = [:api_version] if .key?(:api_version) transport.headers [:headers] if .key?(:headers) end if agent_settings.deprecated_for_removal_transport_configuration_proc agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport) end # Call block to apply any customization, if provided yield(transport) if block_given? end end |
.v7(agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, **options) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/datadog/core/remote/transport/http.rb', line 90 def v7( agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS, ** ) new(Core::Remote::Transport::Config::Transport) do |transport| transport.adapter(agent_settings) transport.headers default_headers apis = API.defaults transport.api API::V7, apis[API::V7] # Apply any settings given by options unless .empty? transport.default_api = [:api_version] if .key?(:api_version) transport.headers [:headers] if .key?(:headers) end if agent_settings.deprecated_for_removal_transport_configuration_proc agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport) end # Call block to apply any customization, if provided yield(transport) if block_given? end end |