Sha256: 631f294ac20292fed08692410c8d83ac6c153164bc6a275d5e013d885fa5f99b

Contents?: true

Size: 1.82 KB

Versions: 22

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module ZipkinTracer
  class TraceContainer
    attr_reader :trace_id, :parent_id, :span_id, :sampled, :flags

    class << self
      attr_accessor :current

      def setup_mock(trace_id:, parent_id:, span_id:, sampled:, flags:)
        @current = new(trace_id: trace_id, parent_id: parent_id, span_id: span_id, sampled: sampled, flags: flags)
      end

      def with_trace_id(trace_id)
        yield trace_id
      end
    end

    def initialize(trace_id:, parent_id:, span_id:, sampled:, flags:)
      @trace_id = trace_id
      @parent_id = parent_id
      @span_id = span_id
      @sampled = sampled
      @flags = flags
    end
  end

  class TraceGenerator
    def next_trace_id
      TraceId.new
    end
  end

  class TraceId
    def trace_id
      'trace_id'
    end

    def parent_id
      'parent_id'
    end

    def span_id
      'span_id'
    end

    def sampled
      ZipkinTracer::TraceContainer.current.sampled
    end

    def flags
      'flags'
    end

    def sampled?
      ZipkinTracer::TraceContainer.current.sampled
    end
  end

  class Span
    def record_tag(*); end

    def record(*); end
  end
end

module Trace
  def self.default_endpoint
    Endpoint.new
  end

  def self.tracer
    Tracer.new
  end

  class Tracer
    def start_span(*)
      return ZipkinTracer::Span.new
    end

    def end_span(*)
      return ZipkinTracer::Span.new
    end
  end

  class Annotation
    CLIENT_SEND = 'client_send'
    CLIENT_RECV = 'client_recv'
  end

  class BinaryAnnotation
    PATH = 'path'
    SERVER_ADDRESS = 'server_address'
    STATUS = 'status'
    ERROR = 'error'

    class Type
      STRING = 'string'
      BOOL = 'bool'
    end
  end

  class Endpoint
    class << self
      def remote_endpoint(*)
        new
      end
    end

    def ip_format
      'ipv4'
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
dhc-3.0.0 spec/support/zipkin_mock.rb
dhc-2.4.0 spec/support/zipkin_mock.rb
dhc-2.3.0 spec/support/zipkin_mock.rb
lhc-15.2.1 spec/support/zipkin_mock.rb
lhc-15.2.0 spec/support/zipkin_mock.rb
lhc-15.1.3 spec/support/zipkin_mock.rb
lhc-15.1.2 spec/support/zipkin_mock.rb
dhc-2.2.1 spec/support/zipkin_mock.rb
dhc-2.2.0 spec/support/zipkin_mock.rb
dhc-2.1.1 spec/support/zipkin_mock.rb
dhc-2.1.0 spec/support/zipkin_mock.rb
dhc-2.0.1 spec/support/zipkin_mock.rb
lhc-15.1.1 spec/support/zipkin_mock.rb
lhc-15.1.0 spec/support/zipkin_mock.rb
lhc-16.0.0.pre.pro2162.2 spec/support/zipkin_mock.rb
lhc-16.0.0.pre.pro2162 spec/support/zipkin_mock.rb
dhc-2.0.0 spec/support/zipkin_mock.rb
lhc-15.0.1 spec/support/zipkin_mock.rb
lhc-15.0.0 spec/support/zipkin_mock.rb
lhc-14.0.0 spec/support/zipkin_mock.rb