Sha256: e863d5581399092e627637d5ebefa3a5d150e6007b1ccf06da327962f03b1890
Contents?: true
Size: 907 Bytes
Versions: 4
Compression:
Stored size: 907 Bytes
Contents
module SpanManager # ThreadLocalManagedSpanSource allows an application access and manipulation of the current span state on per thread basis. class ThreadLocalManagedSpanSource < ManagedSpanSource def make_active(span) active_span = ManagedSpan.new(span, method(:pop)) push(active_span) active_span end def active_span local_stack.last end def clear local_stack.clear end private # Adds the given span to the stack # # @param span [Span] The span to be pushed def push(span) local_stack << span end # Removes a span from the stack # # @return [Span] returns and removes the current span from the top of the stack def pop local_stack.pop end # @return [Array] return a per thread basis stack of spans. def local_stack Thread.current[:__active_span__] ||= [] end end end
Version data entries
4 entries across 4 versions & 1 rubygems