Skip to content

Commit b4f01bb

Browse files
committed
Test refactor
1 parent c990c28 commit b4f01bb

File tree

7 files changed

+26
-70
lines changed

7 files changed

+26
-70
lines changed

instrumentation/http/test/instrumentation/http/instrumentation_test.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,30 @@
3838
_(instrumentation.install({})).must_equal(true)
3939
end
4040
end
41+
42+
describe 'determine_semconv' do
43+
it 'returns "dup" when OTEL_SEMCONV_STABILITY_OPT_IN includes other configs' do
44+
OpenTelemetry::TestHelpers.with_env('OTEL_SEMCONV_STABILITY_OPT_IN' => 'http/dup, database') do
45+
_(determine_semconv).must_equal('dup')
46+
end
47+
end
48+
49+
it 'returns "dup" when OTEL_SEMCONV_STABILITY_OPT_IN includes both http/dup and http' do
50+
OpenTelemetry::TestHelpers.with_env('OTEL_SEMCONV_STABILITY_OPT_IN' => 'http/dup, http') do
51+
_(determine_semconv).must_equal('dup')
52+
end
53+
end
54+
55+
it 'returns "stable" when OTEL_SEMCONV_STABILITY_OPT_IN is http' do
56+
OpenTelemetry::TestHelpers.with_env('OTEL_SEMCONV_STABILITY_OPT_IN' => 'http') do
57+
_(determine_semconv).must_equal('stable')
58+
end
59+
end
60+
61+
it 'returns "old" when OTEL_SEMCONV_STABILITY_OPT_IN is empty' do
62+
OpenTelemetry::TestHelpers.with_env('OTEL_SEMCONV_STABILITY_OPT_IN' => '') do
63+
_(determine_semconv).must_equal('old')
64+
end
65+
end
66+
end
4167
end

instrumentation/http/test/instrumentation/http/patches/dup/client_test.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,6 @@
4444
OpenTelemetry.propagation = @orig_propagation
4545
end
4646

47-
describe 'installation' do
48-
it 'applies the correct patch when stability options include only http/dup and database' do
49-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup, database'
50-
# simulate a fresh install:
51-
instrumentation.instance_variable_set(:@installed, false)
52-
instrumentation.install(config)
53-
54-
_(HTTP::Client.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Dup::Client
55-
end
56-
57-
it 'applies the http/dup patch and excludes the Stable patch when both http and http/dup are present' do
58-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http, http/dup'
59-
# simulate a fresh install:
60-
instrumentation.instance_variable_set(:@installed, false)
61-
instrumentation.install(config)
62-
63-
_(HTTP::Client.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Dup::Client
64-
_(HTTP::Client.ancestors).wont_include OpenTelemetry::Instrumentation::HTTP::Patches::Stable::Client
65-
end
66-
end
67-
6847
describe '#perform' do
6948
it 'traces a simple request' do
7049
HTTP.get('http://example.com/success')

instrumentation/http/test/instrumentation/http/patches/dup/connection_test.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@
2828
instrumentation.instance_variable_set(:@installed, false)
2929
end
3030

31-
describe 'installation' do
32-
it 'installs the patch when env var has multiple configs' do
33-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup, database'
34-
instrumentation.install({}) # simulate a fresh install
35-
36-
_(HTTP::Connection.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Dup::Connection
37-
end
38-
end
39-
4031
describe '#connect' do
4132
it 'emits span on connect' do
4233
WebMock.allow_net_connect!

instrumentation/http/test/instrumentation/http/patches/old/client_test.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@
4242
OpenTelemetry.propagation = @orig_propagation
4343
end
4444

45-
describe 'installation' do
46-
it 'applies the correct patch when stability options do not include HTTP stability modes' do
47-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'database'
48-
# simulate a fresh install:
49-
instrumentation.instance_variable_set(:@installed, false)
50-
instrumentation.install(config)
51-
52-
_(HTTP::Client.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Old::Client
53-
end
54-
end
55-
5645
describe '#perform' do
5746
it 'traces a simple request' do
5847
HTTP.get('http://example.com/success')

instrumentation/http/test/instrumentation/http/patches/old/connection.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@
2424
# Force re-install of instrumentation
2525
after { instrumentation.instance_variable_set(:@installed, false) }
2626

27-
describe 'installation' do
28-
it 'applies the correct patch when stability options do not include HTTP stability modes' do
29-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'database'
30-
instrumentation.install({}) # simulate a fresh install
31-
32-
_(HTTP::Connection.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Old::Connection
33-
end
34-
end
35-
3627
describe '#connect' do
3728
it 'emits span on connect' do
3829
WebMock.allow_net_connect!

instrumentation/http/test/instrumentation/http/patches/stable/client_test.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@
4545
OpenTelemetry.propagation = @orig_propagation
4646
end
4747

48-
describe 'installation' do
49-
it 'applies the correct patch when stability options include only http/dup and database' do
50-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http, database'
51-
# simulate a fresh install:
52-
instrumentation.instance_variable_set(:@installed, false)
53-
instrumentation.install(config)
54-
55-
_(HTTP::Client.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Stable::Client
56-
end
57-
end
58-
5948
describe '#perform' do
6049
it 'traces a simple request' do
6150
HTTP.get('http://example.com/success')

instrumentation/http/test/instrumentation/http/patches/stable/connection.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@
2828
instrumentation.instance_variable_set(:@installed, false)
2929
end
3030

31-
describe 'installation' do
32-
it 'installs the patch when env var has multiple configs' do
33-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup, database'
34-
instrumentation.install({}) # simulate a fresh install
35-
36-
_(HTTP::Connection.ancestors).must_include OpenTelemetry::Instrumentation::HTTP::Patches::Dup::Connection
37-
end
38-
end
39-
4031
describe '#connect' do
4132
it 'emits span on connect' do
4233
WebMock.allow_net_connect!

0 commit comments

Comments
 (0)