File tree Expand file tree Collapse file tree 9 files changed +237
-207
lines changed
lib/opentelemetry/instrumentation/http
test/instrumentation/http Expand file tree Collapse file tree 9 files changed +237
-207
lines changed Original file line number Diff line number Diff line change 44#
55# SPDX-License-Identifier: Apache-2.0
66
7- appraise 'http-4.4' do
8- gem 'http' , '~> 4.4.0'
9- end
7+ # To faclitate HTTP semantic convention stability migration, we are using
8+ # appraisal to test the different semantic convention modes along with different
9+ # HTTP gem versions. For more information on the semantic convention modes, see:
10+ # https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/
11+
12+ semconv_stability = %w[ dup stable old ]
13+
14+ semconv_stability . each do |mode |
15+ appraise "http-4.4 #{ mode } " do
16+ gem 'http' , '~> 4.4.0'
17+ end
1018
11- appraise 'http-3.3.0' do
12- gem 'http' , '~> 3.3.0'
19+ appraise "http-3.3 #{ mode } " do
20+ gem 'http' , '~> 3.3.0'
21+ end
1322end
Original file line number Diff line number Diff line change @@ -64,4 +64,4 @@ def require_dependencies_stable
6464 end
6565 end
6666 end
67- end
67+ end
Original file line number Diff line number Diff line change 99require_relative '../../../lib/opentelemetry/instrumentation/http'
1010
1111describe OpenTelemetry ::Instrumentation ::HTTP do
12+ before { skip unless ENV [ 'BUNDLE_GEMFILE' ] . include? ( 'old' ) }
13+
1214 let ( :instrumentation ) { OpenTelemetry ::Instrumentation ::HTTP ::Instrumentation . instance }
1315
1416 it 'has #name' do
Original file line number Diff line number Diff line change 2020 end
2121 let ( :span_name_formatter ) { nil }
2222
23- ENV [ 'OTEL_SEMCONV_STABILITY_OPT_IN' ] = 'http/dup'
24-
2523 before do
24+ skip unless ENV [ 'BUNDLE_GEMFILE' ] . include? ( 'dup' )
25+
26+ ENV [ 'OTEL_SEMCONV_STABILITY_OPT_IN' ] = 'http/dup'
2627 exporter . reset
2728 @orig_propagation = OpenTelemetry . propagation
2829 propagator = OpenTelemetry ::Trace ::Propagation ::TraceContext . text_map_propagator
3738 end
3839
3940 after do
41+ ENV . delete ( 'OTEL_SEMCONV_STABILITY_OPT_IN' )
4042 # Force re-install of instrumentation
4143 instrumentation . instance_variable_set ( :@installed , false )
4244 OpenTelemetry . propagation = @orig_propagation
4749 HTTP . get ( 'http://example.com/success' )
4850 _ ( exporter . finished_spans . size ) . must_equal ( 1 )
4951 _ ( span . name ) . must_equal 'HTTP GET'
52+
5053 # Old semantic conventions
5154 _ ( span . attributes [ 'http.method' ] ) . must_equal 'GET'
5255 _ ( span . attributes [ 'http.scheme' ] ) . must_equal 'http'
5356 _ ( span . attributes [ 'http.status_code' ] ) . must_equal 200
5457 _ ( span . attributes [ 'http.target' ] ) . must_equal '/success'
5558 _ ( span . attributes [ 'net.peer.name' ] ) . must_equal 'example.com'
5659 _ ( span . attributes [ 'net.peer.port' ] ) . must_equal 80
60+
5761 # Stable semantic conventions
5862 _ ( span . attributes [ 'http.request.method' ] ) . must_equal 'GET'
5963 _ ( span . attributes [ 'url.scheme' ] ) . must_equal 'http'
Original file line number Diff line number Diff line change 1515 let ( :span ) { exporter . finished_spans . first }
1616
1717 before do
18+ skip unless ENV [ 'BUNDLE_GEMFILE' ] . include? ( 'dup' )
19+
20+ ENV [ 'OTEL_SEMCONV_STABILITY_OPT_IN' ] = 'http/dup'
1821 exporter . reset
1922 instrumentation . install ( { } )
2023 end
2124
2225 # Force re-install of instrumentation
2326 after do
27+ ENV . delete ( 'OTEL_SEMCONV_STABILITY_OPT_IN' )
2428 instrumentation . instance_variable_set ( :@installed , false )
2529 end
2630
3842
3943 _ ( exporter . finished_spans . size ) . must_equal ( 2 )
4044 _ ( span . name ) . must_equal 'HTTP CONNECT'
45+
4146 # Old semantic conventions
4247 _ ( span . attributes [ 'net.peer.name' ] ) . must_equal ( 'localhost' )
4348 _ ( span . attributes [ 'net.peer.port' ] ) . wont_be_nil
44- # New semantic conventions
49+
50+ # Stable semantic conventions
4551 _ ( span . attributes [ 'server.address' ] ) . must_equal ( 'localhost' )
4652 _ ( span . attributes [ 'server.port' ] ) . wont_be_nil
4753 ensure
Original file line number Diff line number Diff line change 2121 let ( :span_name_formatter ) { nil }
2222
2323 before do
24+ skip unless ENV [ 'BUNDLE_GEMFILE' ] . include? ( 'old' )
25+
2426 exporter . reset
2527 @orig_propagation = OpenTelemetry . propagation
2628 propagator = OpenTelemetry ::Trace ::Propagation ::TraceContext . text_map_propagator
Original file line number Diff line number Diff line change 1515 let ( :span ) { exporter . finished_spans . first }
1616
1717 before do
18+ skip unless ENV [ 'BUNDLE_GEMFILE' ] . include? ( 'old' )
19+
1820 exporter . reset
1921 instrumentation . install ( { } )
2022 end
You can’t perform that action at this time.
0 commit comments