Commit 0b2e1ab1 authored by Igor's avatar Igor
Browse files

extract thread local into scope_stack method

parent 1b862a0a
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -14,13 +14,11 @@ module Labkit
          def start(name, id, payload)
            scope = OpenTracing.start_active_span(span_name(payload))

            stack = Thread.current[:_labkit_trace_scope_stack] ||= []
            stack.push scope
            scope_stack.push scope
          end

          def finish(name, id, payload)
            stack = Thread.current[:_labkit_trace_scope_stack]
            scope = stack.pop
            scope = scope_stack.pop
            span = scope.span

            exception = payload[:exception]
@@ -33,6 +31,10 @@ module Labkit
            scope.close
          end

          def scope_stack
            Thread.current[:_labkit_trace_scope_stack] ||= []
          end

          def span_name(payload)
            raise "span_name not implemented"
          end