Skip to content

Commit 3f3ff4e

Browse files
committed
Add README and consider database migration env vars
1 parent 7e5f4ff commit 3f3ff4e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

instrumentation/http/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,19 @@ The `opentelemetry-instrumentation-http` gem is distributed under the Apache 2.0
6464
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
6565
[slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
6666
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
67+
68+
## HTTP semantic convention stability
69+
70+
In the OpenTelemetry ecosystem, HTTP semantic conventions have now reached a stable state. However, the initial HTTP instrumentation was introduced before this stability was achieved, which resulted in HTTP attributes being based on an older version of the semantic conventions.
71+
72+
To facilitate the migration to stable semantic conventions, you can use the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable. This variable allows you to opt-in to the new stable conventions, ensuring compatibility and future-proofing your instrumentation.
73+
74+
When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify which conventions you wish to adopt:
75+
76+
- `http` - Emits the stable HTTP and networking conventions and ceases emitting the old conventions previously emitted by the instrumentation.
77+
- `http/dup` - Emits both the old and stable HTTP and networking conventions, enabling a phased rollout of the stable semantic conventions.
78+
- Default behavior (in the absence of either value) is to continue emitting the old HTTP and networking conventions the instrumentation previously emitted.
79+
80+
During the transition from old to stable conventions, HTTP instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to HTTP instrumentation should consider all three patches.
81+
82+
For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
2222
option :span_name_formatter, default: nil, validate: :callable
2323

2424
def determine_semconv
25-
case ENV.fetch('OTEL_SEMCONV_STABILITY_OPT_IN', nil)
26-
when 'http/dup'
25+
stability_opt_in = ENV.fetch('OTEL_SEMCONV_STABILITY_OPT_IN', nil)
26+
values = stability_opt_in&.split(',')
27+
28+
if values.include?('http/dup')
2729
'dup'
28-
when 'http'
30+
elsif values.include?('http')
2931
'stable'
3032
else
3133
'old'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
before do
2424
skip unless ENV['BUNDLE_GEMFILE'].include?('dup')
2525

26-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup'
26+
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup, database'
2727
exporter.reset
2828
@orig_propagation = OpenTelemetry.propagation
2929
propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
before do
1818
skip unless ENV['BUNDLE_GEMFILE'].include?('dup')
1919

20-
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup'
20+
ENV['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http/dup, database'
2121
exporter.reset
2222
instrumentation.install({})
2323
end

0 commit comments

Comments
 (0)