Class: Datadog::Tracing::Transport::Traces::Chunker
- Inherits:
-
Object
- Object
- Datadog::Tracing::Transport::Traces::Chunker
- Defined in:
- lib/datadog/tracing/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): 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.
53 54 55 56 |
# File 'lib/datadog/tracing/transport/traces.rb', line 53 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.
46 47 48 |
# File 'lib/datadog/tracing/transport/traces.rb', line 46 def encoder @encoder end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
46 47 48 |
# File 'lib/datadog/tracing/transport/traces.rb', line 46 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.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/datadog/tracing/transport/traces.rb', line 64 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::Core::Chunker.chunk_by_size(encoded_traces, max_size).map do |chunk| [encoder.join(chunk), chunk.size] end end |