Class: Datadog::Tracing::Flush::Partial

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/tracing/flush.rb

Overview

Consumes and returns completed or partially completed traces from the provided trace_op, if any.

Partial trace flushing avoids large traces residing in memory for too long.

Partially completed traces, where not all spans have finished, will only be returned if there are at least @min_spans_for_partial finished spans.

Spans consumed are removed from trace_op as a side effect.

Constant Summary collapse

DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH =

Start flushing partial trace after this many active spans in one trace

500

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#consume!

Constructor Details

#initialize(options = {}) ⇒ Partial

Returns a new instance of Partial.



82
83
84
85
# File 'lib/datadog/tracing/flush.rb', line 82

def initialize(options = {})
  super()
  @min_spans_for_partial = options.fetch(:min_spans_before_partial_flush, DEFAULT_MIN_SPANS_FOR_PARTIAL_FLUSH)
end

Instance Attribute Details

#min_spans_for_partialObject (readonly)

Returns the value of attribute min_spans_for_partial.



80
81
82
# File 'lib/datadog/tracing/flush.rb', line 80

def min_spans_for_partial
  @min_spans_for_partial
end

Instance Method Details

#flush?(trace_op) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
# File 'lib/datadog/tracing/flush.rb', line 87

def flush?(trace_op)
  return true if trace_op.finished?
  return false if trace_op.finished_span_count < @min_spans_for_partial

  true
end