Sha256: febd5821c97855df28003bb4f919f51f0631d5ae7cb223ed606bd4688c7ebf44

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

# Copyright (c) 2012 by Tracelytics, Inc.
# All rights reserved.

module Oboe
  module API
    module Util
      BACKTRACE_CUTOFF = 100

      # Internal: Check whether the provided key is reserved or not. Reserved
      # keys are either keys that are handled by liboboe calls or the oboe gem.
      #
      # key - the key to check.
      #
      # Return a boolean indicating whether or not key is reserved.
      def valid_key?(key)
        !%w[ Label Layer Edge Timestamp Timestamp_u ].include? key.to_s
      end

      # Internal: Get the current backtrace.
      #
      # ignore - Number of frames to ignore at the end of the backtrace. Use
      #          when you know how many layers deep in oboe the call is being
      #          made.
      #
      # Returns a string with each frame of the backtrace separated by '\r\n'.
      def backtrace(ignore=1)
        frames = Kernel.caller
        frames_len = frames.size
        if frames_len - ignore > BACKTRACE_CUTOFF
          frames[ignore, BACKTRACE_CUTOFF + ignore].unshift("...")
        else
          frames.drop(ignore)
        end.join("\r\n")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
oboe-1.3.0 lib/oboe/api/util.rb
oboe-1.3.1 lib/oboe/api/util.rb
oboe-1.3.2 lib/oboe/api/util.rb
oboe-1.3.3 lib/oboe/api/util.rb
oboe-1.3.4 lib/oboe/api/util.rb
oboe-1.3.5 lib/oboe/api/util.rb
oboe-1.3.6 lib/oboe/api/util.rb
oboe-1.3.7 lib/oboe/api/util.rb