Sha256: 3ae666cbd059e4846f4a159fcdfd5e34cc60da79a5ae7b335128fd19ef78fbb1

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Skylight
  class Trace < Core::Trace

    def initialize(*)
      super
      @too_many_spans = false
    end

    def uuid
      native_get_uuid
    end

    def uuid=(value)
      # We can't change the UUID so just check to make sure we weren't trying to change
      raise "unable to change uuid" unless value == uuid
    end

    def too_many_spans!
      @too_many_spans = true
    end

    def too_many_spans?
      !!@too_many_spans
    end

    def maybe_broken(e)
      if e.is_a?(Skylight::MaximumTraceSpansError) && config.get(:report_max_spans_exceeded)
        too_many_spans!
      else
        super
      end
    end

    def traced
      if too_many_spans?
          error("[E%04d] The request exceeded the maximum number of spans allowed. It will still " \
                  "be tracked but with reduced information. endpoint=%s", Skylight::MaximumTraceSpansError.code, endpoint)
      end

      super
    end

    private

      def track_gc(*)
        # This attempts to log another span which will fail if we have too many
        return if too_many_spans?
        super
      end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skylight-3.0.0 lib/skylight/trace.rb
skylight-3.0.0.beta lib/skylight/trace.rb
skylight-2.0.2 lib/skylight/trace.rb
skylight-2.0.2.beta.1 lib/skylight/trace.rb
skylight-2.0.2.beta lib/skylight/trace.rb
skylight-2.0.1 lib/skylight/trace.rb
skylight-2.0.0 lib/skylight/trace.rb