Module: Datadog::Transport::HTTP
- Defined in:
- lib/ddtrace/transport/http.rb,
lib/ddtrace/transport/http/api.rb,
lib/ddtrace/transport/http/env.rb,
lib/ddtrace/transport/http/client.rb,
lib/ddtrace/transport/http/traces.rb,
lib/ddtrace/transport/http/api/map.rb,
lib/ddtrace/transport/http/builder.rb,
lib/ddtrace/transport/http/api/spec.rb,
lib/ddtrace/transport/http/response.rb,
lib/ddtrace/transport/http/adapters/net.rb,
lib/ddtrace/transport/http/api/endpoint.rb,
lib/ddtrace/transport/http/api/instance.rb,
lib/ddtrace/transport/http/adapters/test.rb,
lib/ddtrace/transport/http/api/fallbacks.rb,
lib/ddtrace/transport/http/adapters/registry.rb,
lib/ddtrace/transport/http/adapters/unix_socket.rb
Overview
Namespace for HTTP transport components
Defined Under Namespace
Modules: API, Adapters, Response, Traces Classes: Builder, Client, Env
Constant Summary collapse
- DEFAULT_AGENT_HOST =
'127.0.0.1'.freeze
- DEFAULT_TRACE_AGENT_PORT =
8126- DEFAULT_HEADERS =
{ 'Datadog-Meta-Lang'.freeze => Datadog::Ext::Runtime::LANG, 'Datadog-Meta-Lang-Version'.freeze => Datadog::Ext::Runtime::LANG_VERSION, 'Datadog-Meta-Lang-Interpreter'.freeze => Datadog::Ext::Runtime::LANG_INTERPRETER, 'Datadog-Meta-Tracer-Version'.freeze => Datadog::Ext::Runtime::TRACER_VERSION }.freeze
Class Method Summary collapse
-
.default(options = {}) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
- .default_hostname ⇒ Object
- .default_port ⇒ Object
-
.new(&block) ⇒ Object
Builds a new Transport::HTTP::Client.
Class Method Details
.default(options = {}) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ddtrace/transport/http.rb', line 33 def default( = {}) new do |transport| transport.adapter :net_http, ENV.fetch('DD_AGENT_HOST', DEFAULT_AGENT_HOST), ENV.fetch('DD_TRACE_AGENT_PORT', DEFAULT_TRACE_AGENT_PORT) transport.headers DEFAULT_HEADERS apis = API.defaults transport.api API::V4, apis[API::V4], fallback: API::V3, default: true transport.api API::V3, apis[API::V3], fallback: API::V2 transport.api API::V2, apis[API::V2] # Apply any settings given by options unless .empty? # Change hostname/port if .key?(:hostname) || .key?(:port) hostname = .fetch(:hostname, default_hostname) port = .fetch(:port, default_port) transport.adapter :net_http, hostname, port end # Change default API transport.default_api = [:api_version] if .key?(:api_version) # Add headers transport.headers [:headers] if .key?(:headers) # Execute on_build callback [:on_build].call(transport) if [:on_build].is_a?(Proc) end # Call block to apply any customization, if provided. yield(transport) if block_given? end end |
.default_hostname ⇒ Object
71 72 73 |
# File 'lib/ddtrace/transport/http.rb', line 71 def default_hostname ENV.fetch('DD_AGENT_HOST', DEFAULT_AGENT_HOST) end |
.default_port ⇒ Object
75 76 77 |
# File 'lib/ddtrace/transport/http.rb', line 75 def default_port ENV.fetch('DD_TRACE_AGENT_PORT', DEFAULT_TRACE_AGENT_PORT) end |
.new(&block) ⇒ Object
Builds a new Transport::HTTP::Client
27 28 29 |
# File 'lib/ddtrace/transport/http.rb', line 27 def new(&block) Builder.new(&block).to_client end |