Skip to content

Commit

Permalink
[tracer] renamed context max_spans -> max_length
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoot committed Nov 15, 2017
1 parent 0220273 commit a5ecc11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/ddtrace/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ module Datadog
# This data structure is thread-safe.
class Context
# 100k spans is about a 100Mb footprint
DEFAULT_MAX_SPANS = 100_000
DEFAULT_MAX_LENGTH = 100_000

attr_reader :max_length

# Initialize a new thread-safe \Context.
def initialize(options = {})
@mutex = Mutex.new
# max_spans is the amount of spans above which, for a
# given trace, the context will simply drop and ignore spans, avoiding
# a high memory usage.
@max_spans = options.fetch(:max_spans,
DEFAULT_MAX_SPANS)
reset
# max_length is the amount of spans above which, for a given trace,
# the context will simply drop and ignore spans, avoiding high memory usage.
@max_length = options.fetch(:max_length, DEFAULT_MAX_LENGTH)
reset(options)
end

def reset(options = {})
Expand Down Expand Up @@ -90,7 +90,7 @@ def add_span(span)
# as it means despite the soft limit, the hard limit is reached, so the trace
# by default has 10000 spans, all of which belong to unfinished parts of a
# larger trace. This is a catch-all to reduce global memory usage.
if @max_spans > 0 && @trace.length >= (@max_spans - 1)
if @max_length > 0 && @trace.length >= (@max_length - 1)
Datadog::Tracer.log.debug("context full, ignoring span #{span.name}")
# This span is going to be finished at some point, but will never increase
# the trace size, so we acknowledge this fact, to avoid to send it to early.
Expand Down
4 changes: 2 additions & 2 deletions lib/ddtrace/context_flush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module Datadog
# It performs memory flushes when required.
class ContextFlush
# by default, soft and hard limits are the same
DEFAULT_MAX_SPANS_BEFORE_PARTIAL_FLUSH = Datadog::Context::DEFAULT_MAX_SPANS
DEFAULT_MAX_SPANS_BEFORE_PARTIAL_FLUSH = Datadog::Context::DEFAULT_MAX_LENGTH
# by default, never do a partial flush
DEFAULT_MIN_SPANS_BEFORE_PARTIAL_FLUSH = Datadog::Context::DEFAULT_MAX_SPANS
DEFAULT_MIN_SPANS_BEFORE_PARTIAL_FLUSH = Datadog::Context::DEFAULT_MAX_LENGTH
# timeout should be lower than the trace agent window
DEFAULT_PARTIAL_FLUSH_TIMEOUT = 10

Expand Down

0 comments on commit a5ecc11

Please sign in to comment.