Sha256: f09dee45a2b0856e3db6c64470f009d610bce44201b0134e76943e48453e724a

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

# frozen-string-literal: true

require "stack_trace/configuration"
require "stack_trace/module_extensions"
require "stack_trace/setup"
require "stack_trace/span"
require "stack_trace/trace"
require "stack_trace/version"

module StackTrace
  TRACED_EVENTS = %i(call c_call return c_return raise).freeze

  class << self
    def configure
      yield configuration
      trace_point.enable
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def trace
      return unless block_given?

      Trace.start
      yield
    end

    def current
      Trace.current
    end

    def as_json
      Trace.as_json
    end

    def trace_point
      @trace_point ||= TracePoint.new(*TRACED_EVENTS) { |tp| Trace.track(tp) }
    end
  end
end

TracePoint.new(:class) do |tp|
  tp.binding.eval <<~RUBY
    self.stack_trace_source_location = __FILE__
  RUBY
end.enable

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stack_trace-0.2.1 lib/stack_trace.rb
stack_trace-0.2.0 lib/stack_trace.rb