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
-
.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
131 132 133 |
# File 'lib/datadog/core/remote/transport/http.rb', line 131 def default_adapter Datadog::Core::Configuration::Ext::Agent::HTTP::ADAPTER end |
.default_headers ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/datadog/core/remote/transport/http.rb', line 109 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::GEM_DATADOG_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? # Sending this header to the agent will disable metrics computation (and billing) on the agent side # by pretending it has already been done on the library side. if Datadog.configuration.appsec.standalone.enabled headers[Datadog::Core::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_STATS] = 'yes' end end 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 |
# 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 # 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.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/datadog/core/remote/transport/http.rb', line 86 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 # Call block to apply any customization, if provided yield(transport) if block_given? end end |