Class: Datadog::DI::Transport::HTTP::Input::API::Endpoint Private

Inherits:
Core::Transport::HTTP::API::Endpoint show all
Defined in:
lib/datadog/di/transport/http/input.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

HEADER_CONTENT_TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Content-Type'

Instance Attribute Summary collapse

Attributes inherited from Core::Transport::HTTP::API::Endpoint

#path, #verb

Instance Method Summary collapse

Constructor Details

#initialize(path, encoder) ⇒ Endpoint

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Endpoint.



47
48
49
50
# File 'lib/datadog/di/transport/http/input.rb', line 47

def initialize(path, encoder)
  super(:post, path)
  @encoder = encoder
end

Instance Attribute Details

#encoderObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/datadog/di/transport/http/input.rb', line 44

def encoder
  @encoder
end

Instance Method Details

#call(env, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/datadog/di/transport/http/input.rb', line 52

def call(env, &block)
  # Encode body & type
  env.headers[HEADER_CONTENT_TYPE] = encoder.content_type
  env.body = env.request.parcel.data
  env.query = {
    # DEV: In theory we could serialize the tags here
    # rather than requiring them to be pre-serialized.
    # In practice the tags should be relatively static
    # (they would change when process forks, and hostname
    # could change at any time but probably we should ignore
    # those changes), therefore serializing the tags
    # every time would be wasteful.
    ddtags: env.request.serialized_tags,
  }

  super
end