Module: Datadog::Core::Transport::HTTP
- Defined in:
- lib/datadog/core/transport/http.rb,
lib/datadog/core/transport/http/env.rb,
lib/datadog/core/transport/http/api/map.rb,
lib/datadog/core/transport/http/builder.rb,
lib/datadog/core/transport/http/api/spec.rb,
lib/datadog/core/transport/http/response.rb,
lib/datadog/core/transport/http/adapters/net.rb,
lib/datadog/core/transport/http/api/endpoint.rb,
lib/datadog/core/transport/http/api/instance.rb,
lib/datadog/core/transport/http/adapters/test.rb,
lib/datadog/core/transport/http/api/fallbacks.rb,
lib/datadog/core/transport/http/adapters/registry.rb,
lib/datadog/core/transport/http/adapters/unix_socket.rb
Overview
HTTP transport
Defined Under Namespace
Modules: API, Adapters, Response Classes: Builder, Env
Class Method Summary collapse
-
.build(api_instance_class:, agent_settings:, logger: Datadog.logger, api_version: nil, headers: nil, &block) ⇒ Object
Helper function that delegates to Builder.new but is under HTTP namespace so that client code requires this file to get the adapters configured, and not the builder directly.
- .default_headers ⇒ Object
Class Method Details
.build(api_instance_class:, agent_settings:, logger: Datadog.logger, api_version: nil, headers: nil, &block) ⇒ Object
Helper function that delegates to Builder.new but is under HTTP namespace so that client code requires this file to get the adapters configured, and not the builder directly.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/datadog/core/transport/http.rb', line 32 def build(api_instance_class:, agent_settings:, logger: Datadog.logger, api_version: nil, headers: nil, &block) Builder.new(api_instance_class: api_instance_class, logger: logger) do |transport| transport.adapter(agent_settings) transport.headers(default_headers) # The caller must define APIs before we set the default API. yield transport # Apply any settings given by options transport.default_api = api_version if api_version transport.headers(headers) if headers end end |
.default_headers ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/datadog/core/transport/http.rb', line 46 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_LANG_INTERPRETER_VENDOR => Core::Environment::Ext::LANG_ENGINE, Datadog::Core::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION => Datadog::Core::Environment::Ext::GEM_DATADOG_VERSION }.tap do |headers| # Add container ID, if present. if (container_id = Datadog::Core::Environment::Container.container_id) headers[Datadog::Core::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id end # TODO: inject configuration rather than reading from global here unless Datadog.configuration.apm.tracing.enabled # 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. headers[Datadog::Core::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_STATS] = 'yes' end end end |