Class: Datadog::Core::Transport::HTTP::Adapters::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/transport/http/adapters/test.rb

Overview

Adapter for testing

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer = nil, **options) ⇒ Test

Deprecated.

Positional parameters are deprecated. Use named parameters instead.

Returns a new instance of Test.

Parameters:

  • buffer (Array) (defaults to: nil)

    an optional array that will capture all spans sent to this adapter, defaults to nil



18
19
20
21
22
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 18

def initialize(buffer = nil, **options)
  @buffer = buffer || options[:buffer]
  @mutex = Mutex.new
  @status = 200
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



12
13
14
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 12

def buffer
  @buffer
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 12

def status
  @status
end

Instance Method Details

#add_request(env) ⇒ Object



33
34
35
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 33

def add_request(env)
  @mutex.synchronize { buffer << env } if buffer?
end

#buffer?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 29

def buffer?
  !@buffer.nil?
end

#call(env) ⇒ Object



24
25
26
27
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 24

def call(env)
  add_request(env)
  Response.new(status)
end

#set_status!(status) ⇒ Object



37
38
39
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 37

def set_status!(status)
  @status = status
end

#urlObject



41
# File 'lib/datadog/core/transport/http/adapters/test.rb', line 41

def url; end