Skip to content

Commit 0cbb1c4

Browse files
committed
feat: semconv testing
1 parent ca200a9 commit 0cbb1c4

File tree

9 files changed

+237
-207
lines changed

9 files changed

+237
-207
lines changed

instrumentation/http/Appraisals

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@
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
1322
end

instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ def require_dependencies_stable
6464
end
6565
end
6666
end
67-
end
67+
end

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
require_relative '../../../lib/opentelemetry/instrumentation/http'
1010

1111
describe 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

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
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
@@ -37,6 +38,7 @@
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
@@ -47,13 +49,15 @@
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'

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
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

@@ -38,10 +42,12 @@
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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
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

instrumentation/http/test/instrumentation/http/patches/old/connection_test.rb renamed to instrumentation/http/test/instrumentation/http/patches/old/connection.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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

0 commit comments

Comments
 (0)