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
Direct Known Subclasses
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.
29 30 31 |
# File 'lib/ddtrace/context_flush.rb', line 29 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.
43 44 45 46 47 48 49 50 |
# File 'lib/ddtrace/context_flush.rb', line 43 def consume!(context) trace, sampled = get_trace(context) return nil unless sampled return trace if trace && !trace.empty? partial_trace(context) end |