opentelemetry-instrumentation-net_http 0.25.1 → 0.26.1

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: 7e15b8c57e2152d2a6ce1a34826c4d72c5c23735abd8d12b501896181c2b2a72
4
- data.tar.gz: 38c24ee4bc41bb6e4c24d48d7d5baa7f69d0b0ad6f8243fc12dde759084ed082
3
+ metadata.gz: d2f9f6258500f5ab93b13a049110172c6debbe70e058c160377fc540a8c994a1
4
+ data.tar.gz: 6c8e7898b77c26263bcb10cd6a5eb393774867ed94d6206dfec07fb4ab3c8bde
5
5
  SHA512:
6
- metadata.gz: eda615c47d1640228b1bba83135348aca267b8874f4aa74089bb496d64e331b42db9fb928cdf5c4b1c1adb7da26b9bbdcaa08af34a6b23c83ca1efa0cccebb9d
7
- data.tar.gz: 0bfec3205c84ba0eaa8f451eb7095cef420fa66c5a16bc19a94ae33c25aa21411a8a4dd7dc13eb51215b23ef888b6ed024b3ccfd48cfbe1209ca51a07796b830
6
+ metadata.gz: 7d4dd3bc8a81c7c6ec0a35f77a6facadd6680a11f8b1fb07c47fb577e7e830356c0bfef62732293f7e096bcc9ff02948eb3096fd72a0c6f2a39d57d00c96e5f7
7
+ data.tar.gz: 4181e65cf2a9b74372f75b81f32a3419f43d77412277f7977d51df038a392b1ee3dcd5ec1b4c60851def8c406575181d7de474e4bcc647562d0e56a72d7e7bbe
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-instrumentation-net_http
2
2
 
3
+ ### v0.26.1 / 2025-11-25
4
+
5
+ * FIXED: Update support for unknown HTTP methods to match semantic conventions
6
+
7
+ ### v0.26.0 / 2025-10-22
8
+
9
+ * BREAKING CHANGE: Min Ruby Version 3.2
10
+
11
+ * ADDED: Min Ruby Version 3.2
12
+
3
13
  ### v0.25.1 / 2025-09-30
4
14
 
5
15
  * FIXED: Min OTel Ruby API 1.7
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module Instrumentation
9
+ module Net
10
+ module HTTP
11
+ # Utility module for HTTP-related helper methods
12
+ # @api private
13
+ module HttpHelper
14
+ # Lightweight struct to hold span creation attributes
15
+ SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
16
+
17
+ # Pre-computed mapping to avoid string allocations during normalization
18
+ METHOD_CACHE = {
19
+ 'CONNECT' => 'CONNECT',
20
+ 'DELETE' => 'DELETE',
21
+ 'GET' => 'GET',
22
+ 'HEAD' => 'HEAD',
23
+ 'OPTIONS' => 'OPTIONS',
24
+ 'PATCH' => 'PATCH',
25
+ 'POST' => 'POST',
26
+ 'PUT' => 'PUT',
27
+ 'TRACE' => 'TRACE',
28
+ 'connect' => 'CONNECT',
29
+ 'delete' => 'DELETE',
30
+ 'get' => 'GET',
31
+ 'head' => 'HEAD',
32
+ 'options' => 'OPTIONS',
33
+ 'patch' => 'PATCH',
34
+ 'post' => 'POST',
35
+ 'put' => 'PUT',
36
+ 'trace' => 'TRACE',
37
+ :connect => 'CONNECT',
38
+ :delete => 'DELETE',
39
+ :get => 'GET',
40
+ :head => 'HEAD',
41
+ :options => 'OPTIONS',
42
+ :patch => 'PATCH',
43
+ :post => 'POST',
44
+ :put => 'PUT',
45
+ :trace => 'TRACE'
46
+ }.freeze
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
60
+
61
+ private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
62
+
63
+ # Prepares all span data for the specified semantic convention in a single call
64
+ # @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)
68
+ normalized = METHOD_CACHE[method]
69
+ 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
+ )
76
+ else
77
+ SpanCreationAttributes.new(
78
+ span_name: 'HTTP',
79
+ normalized_method: '_OTHER',
80
+ original_method: method.to_s
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -23,17 +23,20 @@ module OpenTelemetry
23
23
 
24
24
  return super if untraced?
25
25
 
26
+ span_data = HttpHelper.span_attrs_for(req.method)
27
+
26
28
  attributes = {
27
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => req.method,
29
+ OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
28
30
  OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
29
31
  OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
30
32
  OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
31
33
  OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port,
32
- 'http.request.method' => req.method,
34
+ 'http.request.method' => span_data.normalized_method,
33
35
  'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
34
36
  'server.address' => @address,
35
37
  'server.port' => @port
36
38
  }
39
+ attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
37
40
  path, query = split_path_and_query(req.path)
38
41
  attributes['url.path'] = path
39
42
  attributes['url.query'] = query if query
@@ -41,7 +44,7 @@ module OpenTelemetry
41
44
  attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
42
45
 
43
46
  tracer.in_span(
44
- req.method,
47
+ span_data.span_name,
45
48
  attributes: attributes,
46
49
  kind: :client
47
50
  ) do |span|
@@ -12,7 +12,6 @@ module OpenTelemetry
12
12
  module Old
13
13
  # Module to prepend to Net::HTTP for instrumentation
14
14
  module Instrumentation
15
- HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" }
16
15
  USE_SSL_TO_SCHEME = { false => 'http', true => 'https' }.freeze
17
16
 
18
17
  # Constant for the HTTP status range
@@ -24,8 +23,10 @@ module OpenTelemetry
24
23
 
25
24
  return super if untraced?
26
25
 
26
+ span_data = HttpHelper.span_attrs_for(req.method, semconv: :old)
27
+
27
28
  attributes = {
28
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => req.method,
29
+ OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
29
30
  OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
30
31
  OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
31
32
  OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
@@ -33,7 +34,7 @@ module OpenTelemetry
33
34
  }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
34
35
 
35
36
  tracer.in_span(
36
- HTTP_METHODS_TO_SPAN_NAMES[req.method],
37
+ span_data.span_name,
37
38
  attributes: attributes,
38
39
  kind: :client
39
40
  ) do |span|
@@ -23,12 +23,15 @@ module OpenTelemetry
23
23
 
24
24
  return super if untraced?
25
25
 
26
+ span_data = HttpHelper.span_attrs_for(req.method)
27
+
26
28
  attributes = {
27
- 'http.request.method' => req.method,
29
+ 'http.request.method' => span_data.normalized_method,
28
30
  'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
29
31
  'server.address' => @address,
30
32
  'server.port' => @port
31
33
  }
34
+ attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
32
35
  path, query = split_path_and_query(req.path)
33
36
  attributes['url.path'] = path
34
37
  attributes['url.query'] = query if query
@@ -36,7 +39,7 @@ module OpenTelemetry
36
39
  attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
37
40
 
38
41
  tracer.in_span(
39
- req.method.to_s,
42
+ span_data.span_name,
40
43
  attributes: attributes,
41
44
  kind: :client
42
45
  ) do |span|
@@ -8,7 +8,7 @@ module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Net
10
10
  module HTTP
11
- VERSION = '0.25.1'
11
+ VERSION = '0.26.1'
12
12
  end
13
13
  end
14
14
  end
@@ -18,5 +18,6 @@ module OpenTelemetry
18
18
  end
19
19
  end
20
20
 
21
+ require_relative 'http/http_helper'
21
22
  require_relative 'http/instrumentation'
22
23
  require_relative 'http/version'
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.25.1
4
+ version: 0.26.1
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-10-01 00:00:00.000000000 Z
11
+ date: 2025-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-instrumentation-base
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.24'
19
+ version: '0.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.24'
26
+ version: '0.25'
27
27
  description: Net::HTTP instrumentation for the OpenTelemetry framework
28
28
  email:
29
29
  - cncf-opentelemetry-contributors@lists.cncf.io
@@ -38,6 +38,7 @@ files:
38
38
  - lib/opentelemetry-instrumentation-net_http.rb
39
39
  - lib/opentelemetry/instrumentation.rb
40
40
  - lib/opentelemetry/instrumentation/net/http.rb
41
+ - lib/opentelemetry/instrumentation/net/http/http_helper.rb
41
42
  - lib/opentelemetry/instrumentation/net/http/instrumentation.rb
42
43
  - lib/opentelemetry/instrumentation/net/http/patches/dup/instrumentation.rb
43
44
  - lib/opentelemetry/instrumentation/net/http/patches/old/instrumentation.rb
@@ -47,10 +48,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
47
48
  licenses:
48
49
  - Apache-2.0
49
50
  metadata:
50
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.25.1/file/CHANGELOG.md
51
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.26.1/file/CHANGELOG.md
51
52
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/net_http
52
53
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
53
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.25.1
54
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.26.1
54
55
  post_install_message:
55
56
  rdoc_options: []
56
57
  require_paths:
@@ -59,14 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
60
  requirements:
60
61
  - - ">="
61
62
  - !ruby/object:Gem::Version
62
- version: '3.1'
63
+ version: '3.2'
63
64
  required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - ">="
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.3.27
70
+ rubygems_version: 3.4.19
70
71
  signing_key:
71
72
  specification_version: 4
72
73
  summary: Net::HTTP instrumentation for the OpenTelemetry framework