Class: Datadog::Transport::Traces::Chunker
- Inherits:
-
Object
- Object
- Datadog::Transport::Traces::Chunker
- Defined in:
- lib/ddtrace/transport/traces.rb
Overview
Traces chunker
Constant Summary collapse
- DEFAULT_MAX_PAYLOAD_SIZE =
Trace agent limit payload size of 10 MiB (since agent v5.11.0): https://github.com/DataDog/datadog-agent/blob/6.14.1/pkg/trace/api/api.go#L46
We set the value to a conservative 5 MiB, in case network speed is slow.
5 * 1024 * 1024
Instance Attribute Summary collapse
-
#encoder ⇒ Object
readonly
Returns the value of attribute encoder.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
-
#encode_in_chunks(traces) ⇒ Enumerable[Array[Bytes,Integer]]
Encodes a list of traces in chunks.
-
#initialize(encoder, max_size: DEFAULT_MAX_PAYLOAD_SIZE) ⇒ Chunker
constructor
Single traces larger than +max_size+ will be discarded.
Constructor Details
#initialize(encoder, max_size: DEFAULT_MAX_PAYLOAD_SIZE) ⇒ Chunker
Single traces larger than +max_size+ will be discarded.
49 50 51 52 |
# File 'lib/ddtrace/transport/traces.rb', line 49 def initialize(encoder, max_size: DEFAULT_MAX_PAYLOAD_SIZE) @encoder = encoder @max_size = max_size end |
Instance Attribute Details
#encoder ⇒ Object (readonly)
Returns the value of attribute encoder.
42 43 44 |
# File 'lib/ddtrace/transport/traces.rb', line 42 def encoder @encoder end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
42 43 44 |
# File 'lib/ddtrace/transport/traces.rb', line 42 def max_size @max_size end |
Instance Method Details
#encode_in_chunks(traces) ⇒ Enumerable[Array[Bytes,Integer]]
Encodes a list of traces in chunks. Before serializing, all traces are normalized. Trace nesting is not changed.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ddtrace/transport/traces.rb', line 60 def encode_in_chunks(traces) encoded_traces = if traces.respond_to?(:filter_map) # DEV Supported since Ruby 2.7, saves an intermediate object creation traces.filter_map { |t| encode_one(t) } else traces.map { |t| encode_one(t) }.reject(&:nil?) end Datadog::Chunker.chunk_by_size(encoded_traces, max_size).map do |chunk| [encoder.join(chunk), chunk.size] end end |