Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions instrumentation/faraday/.github-ci.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,27 @@
end
end

describe 'when enable_internal_instrumentation is true' do
let(:client) do
Faraday.new('http://example.com') do |builder|
builder.adapter(:test) do |stub|
stub.get('/success') { |_| [200, {}, 'OK'] }
end
end
end

it 'traces the request without untraced wrapper' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install(enable_internal_instrumentation: true)

client.get('/success')

_(span.name).must_equal 'GET'
_(span.attributes['http.request.method']).must_equal 'GET'
_(span.attributes['http.response.status_code']).must_equal 200
end
end

describe 'url.template in span name' do
let(:client) do
Faraday.new('http://example.com') do |builder|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,26 @@
_(tracers).must_equal 1
end
end

describe 'when enable_internal_instrumentation is true' do
let(:client) do
Faraday.new('http://example.com') do |builder|
builder.adapter(:test) do |stub|
stub.get('/success') { |_| [200, {}, 'OK'] }
end
end
end

it 'traces the request without untraced wrapper' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install(enable_internal_instrumentation: true)

client.get('/success')

_(span.name).must_equal 'HTTP GET'
_(span.attributes['http.method']).must_equal 'GET'
_(span.attributes['http.status_code']).must_equal 200
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@
end
end

describe 'when enable_internal_instrumentation is true' do
let(:client) do
Faraday.new('http://example.com') do |builder|
builder.adapter(:test) do |stub|
stub.get('/success') { |_| [200, {}, 'OK'] }
end
end
end

it 'traces the request without untraced wrapper' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install(enable_internal_instrumentation: true)

client.get('/success')

_(span.name).must_equal 'GET'
_(span.attributes['http.request.method']).must_equal 'GET'
_(span.attributes['http.response.status_code']).must_equal 200
end
end

describe 'url.template in span name' do
let(:client) do
Faraday.new('http://example.com') do |builder|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,65 @@
let(:exporter) { EXPORTER }

before do
skip unless ENV['BUNDLE_GEMFILE'].include?('old')
skip unless ENV['BUNDLE_GEMFILE'].include?('stable')

ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'old'
instrumentation.install
exporter.reset
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install
end

after do
ENV.delete('OTEL_SEMCONV_STABILITY_OPT_IN')
instrumentation.instance_variable_set(:@installed, false)
end

it 'has #name' do
_(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Faraday'
end

it 'has #version' do
_(instrumentation.version).wont_be_nil
_(instrumentation.version).wont_be_empty
end

describe 'present' do
it 'when faraday gem is installed' do
assert instrumentation.present?

Check failure on line 36 in instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb

View workflow job for this annotation

GitHub Actions / RuboCop Check

Minitest/AssertPredicate: Prefer using `assert_predicate(instrumentation, :present?)`.
end

it 'when Faraday is not defined' do
hide_const('Faraday')
refute instrumentation.present?

Check failure on line 41 in instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb

View workflow job for this annotation

GitHub Actions / RuboCop Check

Minitest/RefutePredicate: Prefer using `refute_predicate(instrumentation, :present?)`.
end
end

describe 'compatible' do
it 'when faraday version meets minimum' do
_(instrumentation.compatible?).must_equal true
end
end

describe '#install' do
it 'accepts empty arguments' do
instrumentation.instance_variable_set(:@installed, false)
_(instrumentation.install({})).must_equal true
end
end

describe 'tracing' do
before do
stub_request(:any, 'example.com')
let(:client) do
Faraday.new('http://example.com') do |builder|
builder.adapter(:test) do |stub|
stub.get('/') { [200, {}, 'OK'] }
end
end
end

it 'before request' do
_(exporter.finished_spans.size).must_equal 0
end

it 'after request' do
Faraday.new('http://example.com').get('/')
client.get('/')

_(exporter.finished_spans.size).must_equal 1
end
Expand Down
Loading