Sha256: 2c4563dd060bfef25e2dcf604af3e0b47ea437310daefc50650662dd8e7fb5fc

Contents?: true

Size: 1.73 KB

Versions: 18

Compression:

Stored size: 1.73 KB

Contents

# Copyright (c) 2015 AppNeta, Inc.
# All rights reserved.

require 'minitest_helper'
require 'rack/test'
require 'rack/lobster'
require 'traceview/inst/rack'

class AVWTraceTest  < Minitest::Test
  include Rack::Test::Methods

  def app
    @app = Rack::Builder.new {
      use Rack::CommonLogger
      use Rack::ShowExceptions
      use TraceView::Rack
      map "/lobster" do
        use Rack::Lint
        run Rack::Lobster.new
      end
    }
  end

  def setup
    clear_all_traces
    @tm = TraceView::Config[:tracing_mode]
  end

  def teardown
    TraceView::Config[:tracing_mode] = @tm
  end

  def test_avw_collection_with_through
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :through
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')

    get "/lobster"

    traces = get_all_traces

    traces.count.must_equal 3
    traces[0]['TraceOrigin'].must_equal "avw_sampled"
    validate_outer_layers(traces, 'rack')
  end

  def test_avw_collection_with_always
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :always
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')

    get "/lobster"

    traces = get_all_traces

    traces.count.must_equal 3
    traces[0]['TraceOrigin'].must_equal "always_sampled"
    validate_outer_layers(traces, 'rack')
  end

  def test_avw_collection_with_never
    TV::Config[:tracing_mode] = :never
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')

    get "/lobster"

    traces = get_all_traces
    traces.count.must_equal 0
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
traceview-3.8.1-java test/support/avw_handling_test.rb
traceview-3.8.1 test/support/avw_handling_test.rb
traceview-3.8.0-java test/support/avw_handling_test.rb
traceview-3.8.0 test/support/avw_handling_test.rb
traceview-3.7.1-java test/support/avw_handling_test.rb
traceview-3.7.1 test/support/avw_handling_test.rb
traceview-3.7.0-java test/support/avw_handling_test.rb
traceview-3.7.0 test/support/avw_handling_test.rb
traceview-3.6.0-java test/support/avw_handling_test.rb
traceview-3.6.0 test/support/avw_handling_test.rb
traceview-3.5.1-java test/support/avw_handling_test.rb
traceview-3.5.1 test/support/avw_handling_test.rb
traceview-3.5.0-java test/support/avw_handling_test.rb
traceview-3.5.0 test/support/avw_handling_test.rb
traceview-3.4.2-java test/support/avw_handling_test.rb
traceview-3.4.2 test/support/avw_handling_test.rb
traceview-3.4.1-java test/support/avw_handling_test.rb
traceview-3.4.1 test/support/avw_handling_test.rb