Skip to content

Commit

Permalink
chore: add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlaurin committed May 8, 2024
1 parent e76ee25 commit fe56a27
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,22 @@
end

describe 'config[:untraced_endpoints]' do
let(:service) do
lambda do |_env|
OpenTelemetry.tracer_provider.tracer('req').in_span('in_req_span') {}
[200, { 'Content-Type' => 'text/plain' }, response_body]
end
end

describe 'when an array is passed in' do
let(:uri) { '/ping' }
let(:untraced_endpoints) { ['/ping'] }

it 'does not trace paths listed in the array' do
get '/ping'

ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/ping' }
_(ping_span).must_be_nil

root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' }
_(root_span).wont_be_nil
_(finished_spans.size).must_equal 0
end
end

Expand All @@ -164,19 +169,24 @@
end

describe 'config[:untraced_requests]' do
let(:service) do
lambda do |_env|
OpenTelemetry.tracer_provider.tracer('req').in_span('in_req_span') {}
[200, { 'Content-Type' => 'text/plain' }, response_body]
end
end

describe 'when a callable is passed in' do
let(:uri) { '/assets' }
let(:untraced_requests) do
->(env) { env['PATH_INFO'] =~ %r{^\/assets} }
end

it 'does not trace requests in which the callable returns true' do
get '/assets'

assets_span = finished_spans.find { |s| s.attributes['http.target'] == '/assets' }
_(assets_span).must_be_nil

root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' }
_(root_span).wont_be_nil
_(finished_spans.size).must_equal 0
end
end

Expand Down

0 comments on commit fe56a27

Please sign in to comment.