opentelemetry-instrumentation-net_http 0.26.1 → 0.27.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: d2f9f6258500f5ab93b13a049110172c6debbe70e058c160377fc540a8c994a1
4
- data.tar.gz: 6c8e7898b77c26263bcb10cd6a5eb393774867ed94d6206dfec07fb4ab3c8bde
3
+ metadata.gz: af57eff25e83e807b9fce58534f7354a8da730eeb796e37304e4fcfff10aacf8
4
+ data.tar.gz: e05dab69206fd8a7eadee713bbc057c423b3908f848abf336d52ca974aab119b
5
5
  SHA512:
6
- metadata.gz: 7d4dd3bc8a81c7c6ec0a35f77a6facadd6680a11f8b1fb07c47fb577e7e830356c0bfef62732293f7e096bcc9ff02948eb3096fd72a0c6f2a39d57d00c96e5f7
7
- data.tar.gz: 4181e65cf2a9b74372f75b81f32a3419f43d77412277f7977d51df038a392b1ee3dcd5ec1b4c60851def8c406575181d7de474e4bcc647562d0e56a72d7e7bbe
6
+ metadata.gz: f28c788929d2d2b2330291598b1116586e0ae5f692592ccff42b212cc948c035bc65d639d72391e990881a5326987d74441efea816f64fc82fde1e1ca9ae5cba
7
+ data.tar.gz: 96ec477a7341ac52207adfd0a14b8bc20ebd64445f84b7cbb295d10a9b61be0af1e93a8983792e18cc8112c9b933151b25bc52f500abe01c320406c0384a29f1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-net_http
2
2
 
3
+ ### v0.27.0 / 2026-01-13
4
+
5
+ * ADDED: HTTP Client Semconv v1.17 Span Naming
6
+
3
7
  ### v0.26.1 / 2025-11-25
4
8
 
5
9
  * FIXED: Update support for unknown HTTP methods to match semantic conventions
@@ -93,7 +97,7 @@
93
97
 
94
98
  ### v0.19.4 / 2022-02-02
95
99
 
96
- * FIXED: Clientcontext attrs overwrite in net::http
100
+ * FIXED: Client Context attrs overwrite in net::http
97
101
  * FIXED: Excessive hash creation on context attr merging
98
102
 
99
103
  ### v0.19.3 / 2021-12-01
data/README.md CHANGED
@@ -67,4 +67,4 @@ When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify whic
67
67
 
68
68
  During the transition from old to stable conventions, Net::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 Net::HTTP instrumentation should consider all three patches.
69
69
 
70
- For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
70
+ For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
@@ -12,7 +12,7 @@ module OpenTelemetry
12
12
  # @api private
13
13
  module HttpHelper
14
14
  # Lightweight struct to hold span creation attributes
15
- SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
15
+ SpanCreationAttributes = Struct.new(:span_name, :attributes, keyword_init: true)
16
16
 
17
17
  # Pre-computed mapping to avoid string allocations during normalization
18
18
  METHOD_CACHE = {
@@ -45,41 +45,89 @@ module OpenTelemetry
45
45
  :trace => 'TRACE'
46
46
  }.freeze
47
47
 
48
- # Pre-computed span names for old semantic conventions to avoid allocations
49
- OLD_SPAN_NAMES = {
50
- 'CONNECT' => 'HTTP CONNECT',
51
- 'DELETE' => 'HTTP DELETE',
52
- 'GET' => 'HTTP GET',
53
- 'HEAD' => 'HTTP HEAD',
54
- 'OPTIONS' => 'HTTP OPTIONS',
55
- 'PATCH' => 'HTTP PATCH',
56
- 'POST' => 'HTTP POST',
57
- 'PUT' => 'HTTP PUT',
58
- 'TRACE' => 'HTTP TRACE'
59
- }.freeze
48
+ private_constant :METHOD_CACHE
49
+
50
+ OLD_SPAN_NAMES_BY_METHOD = METHOD_CACHE.values.uniq.each_with_object({}) do |method, hash|
51
+ hash[method] = "HTTP #{method}"
52
+ end.freeze
60
53
 
61
- private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
54
+ private_constant :OLD_SPAN_NAMES_BY_METHOD
62
55
 
63
- # Prepares all span data for the specified semantic convention in a single call
56
+ # Prepares span data using old semantic conventions
64
57
  # @param method [String, Symbol] The HTTP method
65
- # @param semconv [Symbol] The semantic convention to use (:stable or :old)
66
- # @return [SpanCreationAttributes] struct containing span_name, normalized_method, and original_method
67
- def self.span_attrs_for(method, semconv: :stable)
58
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
59
+ def self.span_attrs_for_old(method)
60
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
68
61
  normalized = METHOD_CACHE[method]
62
+ attributes = client_context_attrs.dup
63
+
64
+ # Determine base span name and method value
65
+ if normalized
66
+ span_name = OLD_SPAN_NAMES_BY_METHOD[normalized]
67
+ method_value = normalized
68
+ else
69
+ span_name = 'HTTP'
70
+ method_value = '_OTHER'
71
+ end
72
+
73
+ attributes['http.method'] ||= method_value
74
+
75
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
76
+ end
77
+
78
+ # Prepares span data using stable semantic conventions
79
+ # @param method [String, Symbol] The HTTP method
80
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
81
+ def self.span_attrs_for_stable(method)
82
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
83
+ url_template = client_context_attrs['url.template']
84
+ normalized = METHOD_CACHE[method]
85
+ attributes = client_context_attrs.dup
86
+
87
+ # Determine base span name and method value
69
88
  if normalized
70
- span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
71
- SpanCreationAttributes.new(
72
- span_name: span_name,
73
- normalized_method: normalized,
74
- original_method: nil
75
- )
89
+ base_name = normalized
90
+ method_value = normalized
91
+ original = nil
76
92
  else
77
- SpanCreationAttributes.new(
78
- span_name: 'HTTP',
79
- normalized_method: '_OTHER',
80
- original_method: method.to_s
81
- )
93
+ base_name = 'HTTP'
94
+ method_value = '_OTHER'
95
+ original = method.to_s
82
96
  end
97
+
98
+ span_name = url_template ? "#{base_name} #{url_template}" : base_name
99
+ attributes['http.request.method'] ||= method_value
100
+ attributes['http.request.method_original'] ||= original if original
101
+
102
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
103
+ end
104
+
105
+ # Prepares span data using both old and stable semantic conventions
106
+ # @param method [String, Symbol] The HTTP method
107
+ # @return [SpanCreationAttributes] struct containing span_name and attributes hash
108
+ def self.span_attrs_for_dup(method)
109
+ client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
110
+ url_template = client_context_attrs['url.template']
111
+ normalized = METHOD_CACHE[method]
112
+ attributes = client_context_attrs.dup
113
+
114
+ # Determine base span name and method value
115
+ if normalized
116
+ base_name = normalized
117
+ method_value = normalized
118
+ original = nil
119
+ else
120
+ base_name = 'HTTP'
121
+ method_value = '_OTHER'
122
+ original = method.to_s
123
+ end
124
+
125
+ span_name = url_template ? "#{base_name} #{url_template}" : base_name
126
+ attributes['http.method'] ||= method_value
127
+ attributes['http.request.method'] ||= method_value
128
+ attributes['http.request.method_original'] ||= original if original
129
+
130
+ SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
83
131
  end
84
132
  end
85
133
  end
@@ -23,25 +23,19 @@ module OpenTelemetry
23
23
 
24
24
  return super if untraced?
25
25
 
26
- span_data = HttpHelper.span_attrs_for(req.method)
27
-
28
- attributes = {
29
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
30
- OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
31
- OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
32
- OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
33
- OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port,
34
- 'http.request.method' => span_data.normalized_method,
35
- 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
36
- 'server.address' => @address,
37
- 'server.port' => @port
38
- }
39
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
26
+ span_data = HttpHelper.span_attrs_for_dup(req.method)
27
+
28
+ attributes = { OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
29
+ OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
30
+ OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
31
+ OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port, 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
32
+ 'server.address' => @address,
33
+ 'server.port' => @port }
40
34
  path, query = split_path_and_query(req.path)
41
35
  attributes['url.path'] = path
42
36
  attributes['url.query'] = query if query
43
37
 
44
- attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
38
+ attributes.merge!(span_data.attributes)
45
39
 
46
40
  tracer.in_span(
47
41
  span_data.span_name,
@@ -23,15 +23,12 @@ module OpenTelemetry
23
23
 
24
24
  return super if untraced?
25
25
 
26
- span_data = HttpHelper.span_attrs_for(req.method, semconv: :old)
26
+ span_data = HttpHelper.span_attrs_for_old(req.method)
27
27
 
28
- attributes = {
29
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
30
- OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
31
- OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
32
- OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
33
- OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port
34
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
28
+ attributes = { OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
29
+ OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
30
+ OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
31
+ OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port }.merge!(span_data.attributes)
35
32
 
36
33
  tracer.in_span(
37
34
  span_data.span_name,
@@ -23,20 +23,16 @@ module OpenTelemetry
23
23
 
24
24
  return super if untraced?
25
25
 
26
- span_data = HttpHelper.span_attrs_for(req.method)
26
+ span_data = HttpHelper.span_attrs_for_stable(req.method)
27
27
 
28
- attributes = {
29
- 'http.request.method' => span_data.normalized_method,
30
- 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
31
- 'server.address' => @address,
32
- 'server.port' => @port
33
- }
34
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
28
+ attributes = { 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
29
+ 'server.address' => @address,
30
+ 'server.port' => @port }
35
31
  path, query = split_path_and_query(req.path)
36
32
  attributes['url.path'] = path
37
33
  attributes['url.query'] = query if query
38
34
 
39
- attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
35
+ attributes.merge!(span_data.attributes)
40
36
 
41
37
  tracer.in_span(
42
38
  span_data.span_name,
@@ -8,7 +8,7 @@ module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Net
10
10
  module HTTP
11
- VERSION = '0.26.1'
11
+ VERSION = '0.27.0'
12
12
  end
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-net_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
11
+ date: 2026-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-instrumentation-base
@@ -48,10 +48,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
48
48
  licenses:
49
49
  - Apache-2.0
50
50
  metadata:
51
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.26.1/file/CHANGELOG.md
51
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.27.0/file/CHANGELOG.md
52
52
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/net_http
53
53
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
54
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.26.1
54
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.27.0
55
55
  post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths: