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/statistics.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, Statistics, Traces Classes: Builder, Client, Env
Class Method Summary collapse
-
.default(options = {}) ⇒ Object
Builds a new Transport::HTTP::Client with default settings Pass a block to override any settings.
- .default_headers ⇒ Object
- .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.
27 28 29 30 31 32 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 |
# File 'lib/ddtrace/transport/http.rb', line 27 def default( = {}) new do |transport| transport.adapter :net_http, default_hostname, default_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_headers ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ddtrace/transport/http.rb', line 62 def default_headers { Datadog::Ext::Transport::HTTP::HEADER_META_LANG => Datadog::Ext::Runtime::LANG, Datadog::Ext::Transport::HTTP::HEADER_META_LANG_VERSION => Datadog::Ext::Runtime::LANG_VERSION, Datadog::Ext::Transport::HTTP::HEADER_META_LANG_INTERPRETER => Datadog::Ext::Runtime::LANG_INTERPRETER, Datadog::Ext::Transport::HTTP::HEADER_META_TRACER_VERSION => Datadog::Ext::Runtime::TRACER_VERSION }.tap do |headers| # Add container ID, if present. container_id = Datadog::Runtime::Container.container_id unless container_id.nil? headers[Datadog::Ext::Transport::HTTP::HEADER_CONTAINER_ID] = container_id end end end |
.default_hostname ⇒ Object
77 78 79 |
# File 'lib/ddtrace/transport/http.rb', line 77 def default_hostname ENV.fetch(Datadog::Ext::Transport::HTTP::ENV_DEFAULT_HOST, Datadog::Ext::Transport::HTTP::DEFAULT_HOST) end |
.default_port ⇒ Object
81 82 83 |
# File 'lib/ddtrace/transport/http.rb', line 81 def default_port ENV.fetch(Datadog::Ext::Transport::HTTP::ENV_DEFAULT_PORT, Datadog::Ext::Transport::HTTP::DEFAULT_PORT).to_i end |
.new(&block) ⇒ Object
Builds a new Transport::HTTP::Client
21 22 23 |
# File 'lib/ddtrace/transport/http.rb', line 21 def new(&block) Builder.new(&block).to_client end |