Class: Datadog::CI::TestVisibility::Transport
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::Transport
- Defined in:
- lib/datadog/ci/test_visibility/transport.rb
Constant Summary collapse
- DEFAULT_MAX_PAYLOAD_SIZE =
CI test cycle intake’s limit is 5.1MB uncompressed We will use a bit more conservative value 5MB
5 * 1024 * 1024
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#max_payload_size ⇒ Object
readonly
Returns the value of attribute max_payload_size.
-
#serializers_factory ⇒ Object
readonly
Returns the value of attribute serializers_factory.
Instance Method Summary collapse
-
#initialize(api_key:, url:, env: nil, serializers_factory: Datadog::CI::TestVisibility::Serializers::Factories::TestLevel, max_payload_size: DEFAULT_MAX_PAYLOAD_SIZE) ⇒ Transport
constructor
A new instance of Transport.
- #send_traces(traces) ⇒ Object
Constructor Details
#initialize(api_key:, url:, env: nil, serializers_factory: Datadog::CI::TestVisibility::Serializers::Factories::TestLevel, max_payload_size: DEFAULT_MAX_PAYLOAD_SIZE) ⇒ Transport
Returns a new instance of Transport.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 28 def initialize( api_key:, url:, env: nil, serializers_factory: Datadog::CI::TestVisibility::Serializers::Factories::TestLevel, max_payload_size: DEFAULT_MAX_PAYLOAD_SIZE ) @serializers_factory = serializers_factory @api_key = api_key @max_payload_size = max_payload_size @env = env uri = URI.parse(url) raise "Invalid agentless mode URL: #{url}" if uri.host.nil? @http = Datadog::CI::Transport::HTTP.new( host: uri.host, port: uri.port, ssl: uri.scheme == "https" || uri.port == 443, compress: true ) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
22 23 24 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 22 def api_key @api_key end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
22 23 24 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 22 def env @env end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
22 23 24 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 22 def http @http end |
#max_payload_size ⇒ Object (readonly)
Returns the value of attribute max_payload_size.
22 23 24 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 22 def max_payload_size @max_payload_size end |
#serializers_factory ⇒ Object (readonly)
Returns the value of attribute serializers_factory.
22 23 24 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 22 def serializers_factory @serializers_factory end |
Instance Method Details
#send_traces(traces) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/datadog/ci/test_visibility/transport.rb', line 52 def send_traces(traces) return [] if traces.nil? || traces.empty? Datadog.logger.debug { "Sending #{traces.count} traces..." } encoded_events = encode_traces(traces) if encoded_events.empty? Datadog.logger.debug { "Empty encoded events list, skipping send" } return [] end responses = [] Datadog::Core::Chunker.chunk_by_size(encoded_events, max_payload_size).map do |chunk| encoded_payload = pack_events(chunk) Datadog.logger.debug do "Send chunk of #{chunk.count} events; payload size #{encoded_payload.size}" end response = send_payload(encoded_payload) Datadog.logger.debug do "Received server response: #{response.inspect}" end responses << response end responses end |