Class: Datadog::ContextFlush::Partial
- Inherits:
-
Object
- Object
- Datadog::ContextFlush::Partial
- Defined in:
- lib/ddtrace/context_flush.rb
Overview
Performs partial trace flushing to avoid large traces residing in memory for too long
Constant Summary collapse
- DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH =
Start flushing partial trace after this many active spans in one trace
500
Instance Method Summary collapse
-
#consume!(context) ⇒ Array<Span>
Consumes and returns completed or partially completed traces from the provided
context, if any. -
#initialize(options = {}) ⇒ Partial
constructor
A new instance of Partial.
Constructor Details
#initialize(options = {}) ⇒ Partial
Returns a new instance of Partial.
22 23 24 |
# File 'lib/ddtrace/context_flush.rb', line 22 def initialize( = {}) @min_spans_for_partial = .fetch(:min_spans_before_partial_flush, DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH) end |
Instance Method Details
#consume!(context) ⇒ Array<Span>
Consumes and returns completed or partially completed traces from the provided context, if any.
Partially completed traces, where not all spans have finished, will only be returned if there are at least @min_spans_for_partial finished spans.
Any spans consumed are removed from context as a side effect.
36 37 38 39 40 41 42 43 |
# File 'lib/ddtrace/context_flush.rb', line 36 def consume!(context) trace, sampled = context.get return nil unless sampled return trace if trace && !trace.empty? partial_trace(context) end |