Class: XRay::DefaultStreamer
- Inherits:
-
Object
- Object
- XRay::DefaultStreamer
- Defined in:
- lib/aws-xray-sdk/streaming/default_streamer.rb
Overview
The default streamer use subsegment count as the threshold for performance reasons and it streams out subtrees where all the nodes in it are completed.
Instance Attribute Summary collapse
-
#stream_threshold ⇒ Integer
The maximum number of subsegments a segment can hold before streaming.
Instance Method Summary collapse
- #eligible?(segment:) ⇒ Boolean
-
#initialize ⇒ DefaultStreamer
constructor
A new instance of DefaultStreamer.
- #stream_subsegments(root:, emitter:) ⇒ Object
Methods included from Logging
Methods included from Streamer
Constructor Details
#initialize ⇒ DefaultStreamer
Returns a new instance of DefaultStreamer.
12 13 14 |
# File 'lib/aws-xray-sdk/streaming/default_streamer.rb', line 12 def initialize @stream_threshold = 50 end |
Instance Attribute Details
#stream_threshold ⇒ Integer
Returns The maximum number of subsegments a segment can hold before streaming.
51 52 53 |
# File 'lib/aws-xray-sdk/streaming/default_streamer.rb', line 51 def stream_threshold @stream_threshold end |
Instance Method Details
#eligible?(segment:) ⇒ Boolean
18 19 20 21 |
# File 'lib/aws-xray-sdk/streaming/default_streamer.rb', line 18 def eligible?(segment:) # only get subsegments to stream from sampled segments. segment && segment.sampled && segment.subsegment_size >= stream_threshold end |
#stream_subsegments(root:, emitter:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/aws-xray-sdk/streaming/default_streamer.rb', line 25 def stream_subsegments(root:, emitter:) children = root.subsegments children_ready = [] unless children.empty? # Collect ready subtrees from root. children.each do |child| children_ready << child if stream_subsegments root: child, emitter: emitter end end # If this subtree is ready, go back to the root's parent # to try to find a bigger subtree return true if children_ready.length == children.length && root.closed? # Otherwise this subtree has at least one non-ready node. # Only stream its ready child subtrees. children_ready.each do |child| root.remove_subsegment subsegment: child emitter.send_entity entity: child end # Return false so this node won't be added to its parent's ready children. false end |