Class: Datadog::Tracing::Transport::HTTP::API::Instance

Inherits:
Object
  • Object
show all
Includes:
Traces::API::Instance
Defined in:
lib/datadog/tracing/transport/http/api/instance.rb

Overview

An API configured with adapter and routes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Traces::API::Instance

#send_traces

Constructor Details

#initialize(spec, adapter, options = {}) ⇒ Instance

Returns a new instance of Instance.



15
16
17
18
19
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 15

def initialize(spec, adapter, options = {})
  @spec = spec
  @adapter = adapter
  @headers = options.fetch(:headers, {})
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



10
11
12
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 10

def adapter
  @adapter
end

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 10

def headers
  @headers
end

#specObject (readonly)

Returns the value of attribute spec.



10
11
12
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 10

def spec
  @spec
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 25

def call(env)
  # Add headers to request env, unless empty.
  env.headers.merge!(headers) unless headers.empty?

  # Send request env to the adapter.
  adapter.call(env)
end

#encoderObject



21
22
23
# File 'lib/datadog/tracing/transport/http/api/instance.rb', line 21

def encoder
  spec.encoder
end