opentelemetry-instrumentation-http_client 0.26.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ebfac04300052a282f08d6ad26b6aea718d46973e89be8583b66e11ac598e06
4
- data.tar.gz: 5f20e179aee50b6c64778d09ed1f0d8afcf0703bea09f1caf50eca3eeba71a7d
3
+ metadata.gz: a94b8067f84bca1dd487affdceb4cda269bc8af1c965ef7e76a951d1c4c04bac
4
+ data.tar.gz: 500a80d8f273638f42ac6b7ef6ecf6899a701fdb97b449c84012520949f6d41b
5
5
  SHA512:
6
- metadata.gz: 76bfb9567d20b11bb08d8d1c040bdccbe59f643cb4c9001687a1c4dc8f7475824bb9c20e0d709fb4352170daf16cb34aff8c415cbf5e78c4a6d9147ca5d4d6ea
7
- data.tar.gz: 5383ad9c9c9cdcc2bfa8d193c56fb4fc918c3785e961375c8396ebd09c3ae3a3b663eb5217e974ac920700de58a5c9e7658ef456723197c0dc1958a956ab492a
6
+ metadata.gz: 01c2ebc9d8c8110cfb4c0ddb4b2d64a0c28aeb492da75ee3ee39dffbb8ed2b7bbc44e9996b14a680a7592c5d38f97ca4f57aeaef50241d3d0fc1c980dd134e26
7
+ data.tar.gz: 11655cdc285e2a617339ff52752232eeba6cd844100ae4ed87f47a2155d0eddffdce51f547759f515b3f5f0ba531d8cebff9d286565d0358992aba4344938746
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History: opentelemetry-instrumentation-http_client
2
2
 
3
+ ### v0.28.0 / 2026-03-17
4
+
5
+ * BREAKING CHANGE: Default to stable HTTP semantic conventions (#2051)
6
+ * ADDED: Default to stable HTTP semantic conventions (#2051)
7
+
8
+ ### v0.27.0 / 2026-01-13
9
+
10
+ * ADDED: HTTP Client Semconv v1.17 Span Naming
11
+
3
12
  ### v0.26.1 / 2025-11-25
4
13
 
5
14
  * FIXED: Update support for unknown HTTP methods to match semantic conventions
@@ -7,7 +16,6 @@
7
16
  ### v0.26.0 / 2025-10-22
8
17
 
9
18
  * BREAKING CHANGE: Min Ruby Version 3.2
10
-
11
19
  * ADDED: Min Ruby Version 3.2
12
20
 
13
21
  ### v0.25.1 / 2025-09-30
@@ -25,7 +33,6 @@
25
33
  ### v0.23.0 / 2025-01-16
26
34
 
27
35
  * BREAKING CHANGE: Set minimum supported version to Ruby 3.1
28
-
29
36
  * ADDED: Set minimum supported version to Ruby 3.1
30
37
 
31
38
  ### v0.22.8 / 2024-11-26
@@ -63,7 +70,6 @@
63
70
  ### v0.22.0 / 2023-04-17
64
71
 
65
72
  * BREAKING CHANGE: Drop support for EoL Ruby 2.7
66
-
67
73
  * ADDED: Drop support for EoL Ruby 2.7
68
74
 
69
75
  ### v0.21.0 / 2023-01-14
@@ -100,7 +106,6 @@
100
106
  ### v0.19.0 / 2021-06-23
101
107
 
102
108
  * BREAKING CHANGE: Total order constraint on span.status=
103
-
104
109
  * FIXED: Total order constraint on span.status=
105
110
 
106
111
  ### v0.18.0 / 2021-05-21
data/README.md CHANGED
@@ -55,16 +55,12 @@ The `opentelemetry-instrumentation-http_client` gem is distributed under the Apa
55
55
 
56
56
  ## HTTP semantic convention stability
57
57
 
58
- In the OpenTelemetry ecosystem, HTTP semantic conventions have now reached a stable state. However, the initial HttpClient instrumentation was introduced before this stability was achieved, which resulted in HTTP attributes being based on an older version of the semantic conventions.
59
-
60
- 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.
58
+ This instrumentation by default emits the stable HTTP semantic conventions. The `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable can be used to opt-in to the old or duplicate (both old and stable) semantic conventions.
61
59
 
62
60
  When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify which conventions you wish to adopt:
63
61
 
64
- - `http` - Emits the stable HTTP and networking conventions and ceases emitting the old conventions previously emitted by the instrumentation.
65
- - `http/dup` - Emits both the old and stable HTTP and networking conventions, enabling a phased rollout of the stable semantic conventions.
66
- - Default behavior (in the absence of either value) is to continue emitting the old HTTP and networking conventions the instrumentation previously emitted.
67
-
68
- During the transition from old to stable conventions, HttpClient instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to HttpClient instrumentation should consider all three patches.
62
+ - `http` - Emits the stable HTTP and networking conventions.
63
+ - `http/dup` - **DEPRECATED: Will be removed on April 15, 2026.** Emits both the old and stable HTTP and networking conventions.
64
+ - `old` - **DEPRECATED: Will be removed on April 15, 2026.** Emits the old HTTP and networking conventions.
69
65
 
70
- For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
66
+ For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
@@ -11,7 +11,7 @@ module OpenTelemetry
11
11
  # @api private
12
12
  module HttpHelper
13
13
  # Lightweight struct to hold span creation attributes
14
- SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
14
+ SpanCreationAttributes = Struct.new(:span_name, :attributes)
15
15
 
16
16
  # Pre-computed mapping to avoid string allocations during normalization
17
17
  METHOD_CACHE = {
@@ -44,41 +44,89 @@ module OpenTelemetry
44
44
  :trace => 'TRACE'
45
45
  }.freeze
46
46
 
47
- # Pre-computed span names for old semantic conventions to avoid allocations
48
- OLD_SPAN_NAMES = {
49
- 'CONNECT' => 'HTTP CONNECT',
50
- 'DELETE' => 'HTTP DELETE',
51
- 'GET' => 'HTTP GET',
52
- 'HEAD' => 'HTTP HEAD',
53
- 'OPTIONS' => 'HTTP OPTIONS',
54
- 'PATCH' => 'HTTP PATCH',
55
- 'POST' => 'HTTP POST',
56
- 'PUT' => 'HTTP PUT',
57
- 'TRACE' => 'HTTP TRACE'
58
- }.freeze
47
+ private_constant :METHOD_CACHE
48
+
49
+ OLD_SPAN_NAMES_BY_METHOD = METHOD_CACHE.values.uniq.to_h do |method|
50
+ [method, "HTTP #{method}"]
51
+ end.freeze
59
52
 
60
- private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
53
+ private_constant :OLD_SPAN_NAMES_BY_METHOD
61
54
 
62
- # Prepares all span data for the specified semantic convention in a single call
55
+ # Prepares span data using old semantic conventions
63
56
  # @param method [String, Symbol] The HTTP method
64
- # @param semconv [Symbol] The semantic convention to use (:stable or :old)
65
- # @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
66
- def self.span_attrs_for(method, semconv: :stable)
57
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
58
+ def self.span_attrs_for_old(method)
59
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
67
60
  normalized = METHOD_CACHE[method]
61
+ attributes = client_context_attrs.dup
62
+
63
+ # Determine base span name and method value
64
+ if normalized
65
+ span_name = OLD_SPAN_NAMES_BY_METHOD[normalized]
66
+ method_value = normalized
67
+ else
68
+ span_name = 'HTTP'
69
+ method_value = '_OTHER'
70
+ end
71
+
72
+ attributes['http.method'] ||= method_value
73
+
74
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
75
+ end
76
+
77
+ # Prepares span data using stable semantic conventions
78
+ # @param method [String, Symbol] The HTTP method
79
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
80
+ def self.span_attrs_for_stable(method)
81
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
82
+ url_template = client_context_attrs['url.template']
83
+ normalized = METHOD_CACHE[method]
84
+ attributes = client_context_attrs.dup
85
+
86
+ # Determine base span name and method value
68
87
  if normalized
69
- span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
70
- SpanCreationAttributes.new(
71
- span_name: span_name,
72
- normalized_method: normalized,
73
- original_method: nil
74
- )
88
+ base_name = normalized
89
+ method_value = normalized
90
+ original = nil
75
91
  else
76
- SpanCreationAttributes.new(
77
- span_name: 'HTTP',
78
- normalized_method: '_OTHER',
79
- original_method: method.to_s
80
- )
92
+ base_name = 'HTTP'
93
+ method_value = '_OTHER'
94
+ original = method.to_s
81
95
  end
96
+
97
+ span_name = url_template ? "#{base_name} #{url_template}" : base_name
98
+ attributes['http.request.method'] ||= method_value
99
+ attributes['http.request.method_original'] ||= original if original
100
+
101
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
102
+ end
103
+
104
+ # Prepares span data using both old and stable semantic conventions
105
+ # @param method [String, Symbol] The HTTP method
106
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
107
+ def self.span_attrs_for_dup(method)
108
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
109
+ url_template = client_context_attrs['url.template']
110
+ normalized = METHOD_CACHE[method]
111
+ attributes = client_context_attrs.dup
112
+
113
+ # Determine base span name and method value
114
+ if normalized
115
+ base_name = normalized
116
+ method_value = normalized
117
+ original = nil
118
+ else
119
+ base_name = 'HTTP'
120
+ method_value = '_OTHER'
121
+ original = method.to_s
122
+ end
123
+
124
+ span_name = url_template ? "#{base_name} #{url_template}" : base_name
125
+ attributes['http.method'] ||= method_value
126
+ attributes['http.request.method'] ||= method_value
127
+ attributes['http.request.method_original'] ||= original if original
128
+
129
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
82
130
  end
83
131
  end
84
132
  end
@@ -28,14 +28,20 @@ module OpenTelemetry
28
28
  values = stability_opt_in.split(',').map(&:strip)
29
29
 
30
30
  if values.include?('http/dup')
31
+ emit_old_semconv_deprecation_warning('http/dup')
31
32
  'dup'
32
- elsif values.include?('http')
33
- 'stable'
34
- else
33
+ elsif values.include?('old')
34
+ emit_old_semconv_deprecation_warning('old')
35
35
  'old'
36
+ else
37
+ 'stable'
36
38
  end
37
39
  end
38
40
 
41
+ def emit_old_semconv_deprecation_warning(option)
42
+ OpenTelemetry.logger.warn("The `#{option}` option for OTEL_SEMCONV_STABILITY_OPT_IN is deprecated and will be removed on April 15, 2026. Please migrate to the stable HTTP semantic conventions.")
43
+ end
44
+
39
45
  def patch_dup
40
46
  ::HTTPClient.prepend(Patches::Dup::Client)
41
47
  ::HTTPClient::Session.prepend(Patches::Dup::Session)
@@ -20,25 +20,22 @@ module OpenTelemetry
20
20
  uri = req.header.request_uri
21
21
  url = "#{uri.scheme}://#{uri.host}"
22
22
  request_method = req.header.request_method
23
- span_data = HttpHelper.span_attrs_for(request_method)
23
+ span_data = HttpHelper.span_attrs_for_dup(request_method)
24
24
 
25
25
  attributes = {
26
- 'http.method' => span_data.normalized_method,
27
26
  'http.scheme' => uri.scheme,
28
27
  'http.target' => uri.path,
29
28
  'http.url' => url,
30
29
  'net.peer.name' => uri.host,
31
30
  'net.peer.port' => uri.port,
32
31
  # stable semantic conventions
33
- 'http.request.method' => span_data.normalized_method,
34
32
  'url.scheme' => uri.scheme,
35
33
  'url.path' => uri.path,
36
34
  'url.full' => url,
37
35
  'server.address' => uri.host,
38
36
  'server.port' => uri.port
39
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
37
+ }.merge!(span_data.attributes)
40
38
 
41
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
42
39
  attributes['url.query'] = uri.query unless uri.query.nil?
43
40
 
44
41
  tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
@@ -20,16 +20,16 @@ module OpenTelemetry
20
20
  uri = req.header.request_uri
21
21
  url = "#{uri.scheme}://#{uri.host}"
22
22
  request_method = req.header.request_method
23
- span_data = HttpHelper.span_attrs_for(request_method, semconv: :old)
23
+
24
+ span_data = HttpHelper.span_attrs_for_old(request_method)
24
25
 
25
26
  attributes = {
26
- 'http.method' => span_data.normalized_method,
27
27
  'http.scheme' => uri.scheme,
28
28
  'http.target' => uri.path,
29
29
  'http.url' => url,
30
30
  'net.peer.name' => uri.host,
31
31
  'net.peer.port' => uri.port
32
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
32
+ }.merge!(span_data.attributes)
33
33
 
34
34
  tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
35
35
  OpenTelemetry.propagation.inject(req.header)
@@ -20,18 +20,15 @@ module OpenTelemetry
20
20
  uri = req.header.request_uri
21
21
  url = "#{uri.scheme}://#{uri.host}"
22
22
  request_method = req.header.request_method
23
- span_data = HttpHelper.span_attrs_for(request_method)
24
23
 
25
- attributes = {
26
- 'http.request.method' => span_data.normalized_method,
27
- 'url.scheme' => uri.scheme,
28
- 'url.path' => uri.path,
29
- 'url.full' => url,
30
- 'server.address' => uri.host,
31
- 'server.port' => uri.port
32
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
24
+ span_data = HttpHelper.span_attrs_for_stable(request_method)
25
+
26
+ attributes = { 'url.scheme' => uri.scheme,
27
+ 'url.path' => uri.path,
28
+ 'url.full' => url,
29
+ 'server.address' => uri.host,
30
+ 'server.port' => uri.port }.merge!(span_data.attributes)
33
31
 
34
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
35
32
  attributes['url.query'] = uri.query unless uri.query.nil?
36
33
 
37
34
  tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module HttpClient
10
- VERSION = '0.26.1'
10
+ VERSION = '0.28.0'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-http_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: opentelemetry-instrumentation-base
@@ -51,11 +50,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
51
50
  licenses:
52
51
  - Apache-2.0
53
52
  metadata:
54
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.1/file/CHANGELOG.md
53
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.28.0/file/CHANGELOG.md
55
54
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http_client
56
55
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
57
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.1
58
- post_install_message:
56
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.28.0
59
57
  rdoc_options: []
60
58
  require_paths:
61
59
  - lib
@@ -70,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
68
  - !ruby/object:Gem::Version
71
69
  version: '0'
72
70
  requirements: []
73
- rubygems_version: 3.4.19
74
- signing_key:
71
+ rubygems_version: 4.0.3
75
72
  specification_version: 4
76
73
  summary: HttpClient instrumentation for the OpenTelemetry framework
77
74
  test_files: []