opentelemetry-instrumentation-http_client 0.26.0 → 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: 173a5c572cbaf59ec176945876b38627014fbf069a9f12a6e940b7b7b1ea8600
4
- data.tar.gz: 47d7e1efebbd6921459e64035cba102c7beb639fc411760f2ac5d5b1f756c06d
3
+ metadata.gz: 9ebfac04300052a282f08d6ad26b6aea718d46973e89be8583b66e11ac598e06
4
+ data.tar.gz: 5f20e179aee50b6c64778d09ed1f0d8afcf0703bea09f1caf50eca3eeba71a7d
5
5
  SHA512:
6
- metadata.gz: e8a46e0f0102b6743f3b73a6bbfed4b555249e3fe4314b2163f169cf27a7d13bc42597731a37dfa8970a0b19add688221a2875f9fd309ca5fde53c33c3dfd092
7
- data.tar.gz: '0965757a3c4a87a130e7f7056b66be0f7b26d428451a574cc82a09e6a02406d8ccc102654ea53f0b947608dad2831f5c208d2411723d643d18c5c761764f4a56'
6
+ metadata.gz: 76bfb9567d20b11bb08d8d1c040bdccbe59f643cb4c9001687a1c4dc8f7475824bb9c20e0d709fb4352170daf16cb34aff8c415cbf5e78c4a6d9147ca5d4d6ea
7
+ data.tar.gz: 5383ad9c9c9cdcc2bfa8d193c56fb4fc918c3785e961375c8396ebd09c3ae3a3b663eb5217e974ac920700de58a5c9e7658ef456723197c0dc1958a956ab492a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-http_client
2
2
 
3
+ ### v0.26.1 / 2025-11-25
4
+
5
+ * FIXED: Update support for unknown HTTP methods to match semantic conventions
6
+
3
7
  ### v0.26.0 / 2025-10-22
4
8
 
5
9
  * BREAKING CHANGE: Min Ruby Version 3.2
@@ -0,0 +1,86 @@
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 HttpClient
10
+ # Module for normalizing HTTP methods
11
+ # @api private
12
+ module HttpHelper
13
+ # Lightweight struct to hold span creation attributes
14
+ SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
15
+
16
+ # Pre-computed mapping to avoid string allocations during normalization
17
+ METHOD_CACHE = {
18
+ 'CONNECT' => 'CONNECT',
19
+ 'DELETE' => 'DELETE',
20
+ 'GET' => 'GET',
21
+ 'HEAD' => 'HEAD',
22
+ 'OPTIONS' => 'OPTIONS',
23
+ 'PATCH' => 'PATCH',
24
+ 'POST' => 'POST',
25
+ 'PUT' => 'PUT',
26
+ 'TRACE' => 'TRACE',
27
+ 'connect' => 'CONNECT',
28
+ 'delete' => 'DELETE',
29
+ 'get' => 'GET',
30
+ 'head' => 'HEAD',
31
+ 'options' => 'OPTIONS',
32
+ 'patch' => 'PATCH',
33
+ 'post' => 'POST',
34
+ 'put' => 'PUT',
35
+ 'trace' => 'TRACE',
36
+ :connect => 'CONNECT',
37
+ :delete => 'DELETE',
38
+ :get => 'GET',
39
+ :head => 'HEAD',
40
+ :options => 'OPTIONS',
41
+ :patch => 'PATCH',
42
+ :post => 'POST',
43
+ :put => 'PUT',
44
+ :trace => 'TRACE'
45
+ }.freeze
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
59
+
60
+ private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
61
+
62
+ # Prepares all span data for the specified semantic convention in a single call
63
+ # @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)
67
+ normalized = METHOD_CACHE[method]
68
+ 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
+ )
75
+ else
76
+ SpanCreationAttributes.new(
77
+ span_name: 'HTTP',
78
+ normalized_method: '_OTHER',
79
+ original_method: method.to_s
80
+ )
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -20,16 +20,17 @@ 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
24
 
24
25
  attributes = {
25
- 'http.method' => request_method,
26
+ 'http.method' => span_data.normalized_method,
26
27
  'http.scheme' => uri.scheme,
27
28
  'http.target' => uri.path,
28
29
  'http.url' => url,
29
30
  'net.peer.name' => uri.host,
30
31
  'net.peer.port' => uri.port,
31
32
  # stable semantic conventions
32
- 'http.request.method' => request_method,
33
+ 'http.request.method' => span_data.normalized_method,
33
34
  'url.scheme' => uri.scheme,
34
35
  'url.path' => uri.path,
35
36
  'url.full' => url,
@@ -37,9 +38,10 @@ module OpenTelemetry
37
38
  'server.port' => uri.port
38
39
  }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
39
40
 
41
+ attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
40
42
  attributes['url.query'] = uri.query unless uri.query.nil?
41
43
 
42
- tracer.in_span(request_method, attributes: attributes, kind: :client) do |span|
44
+ tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
43
45
  OpenTelemetry.propagation.inject(req.header)
44
46
  super.tap do
45
47
  response = conn.pop
@@ -20,9 +20,10 @@ 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
 
24
25
  attributes = {
25
- 'http.method' => request_method,
26
+ 'http.method' => span_data.normalized_method,
26
27
  'http.scheme' => uri.scheme,
27
28
  'http.target' => uri.path,
28
29
  'http.url' => url,
@@ -30,7 +31,7 @@ module OpenTelemetry
30
31
  'net.peer.port' => uri.port
31
32
  }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
32
33
 
33
- tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span|
34
+ tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
34
35
  OpenTelemetry.propagation.inject(req.header)
35
36
  super.tap do
36
37
  response = conn.pop
@@ -20,9 +20,10 @@ 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
24
 
24
25
  attributes = {
25
- 'http.request.method' => request_method,
26
+ 'http.request.method' => span_data.normalized_method,
26
27
  'url.scheme' => uri.scheme,
27
28
  'url.path' => uri.path,
28
29
  'url.full' => url,
@@ -30,9 +31,10 @@ module OpenTelemetry
30
31
  'server.port' => uri.port
31
32
  }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
32
33
 
34
+ attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
33
35
  attributes['url.query'] = uri.query unless uri.query.nil?
34
36
 
35
- tracer.in_span(request_method, attributes: attributes, kind: :client) do |span|
37
+ tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
36
38
  OpenTelemetry.propagation.inject(req.header)
37
39
  super.tap do
38
40
  response = conn.pop
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module HttpClient
10
- VERSION = '0.26.0'
10
+ VERSION = '0.26.1'
11
11
  end
12
12
  end
13
13
  end
@@ -15,5 +15,6 @@ module OpenTelemetry
15
15
  end
16
16
  end
17
17
 
18
+ require_relative 'http_client/http_helper'
18
19
  require_relative 'http_client/instrumentation'
19
20
  require_relative 'http_client/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-http_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
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-22 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
@@ -38,6 +38,7 @@ files:
38
38
  - lib/opentelemetry-instrumentation-http_client.rb
39
39
  - lib/opentelemetry/instrumentation.rb
40
40
  - lib/opentelemetry/instrumentation/http_client.rb
41
+ - lib/opentelemetry/instrumentation/http_client/http_helper.rb
41
42
  - lib/opentelemetry/instrumentation/http_client/instrumentation.rb
42
43
  - lib/opentelemetry/instrumentation/http_client/patches/dup/client.rb
43
44
  - lib/opentelemetry/instrumentation/http_client/patches/dup/session.rb
@@ -50,10 +51,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
50
51
  licenses:
51
52
  - Apache-2.0
52
53
  metadata:
53
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.0/file/CHANGELOG.md
54
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.1/file/CHANGELOG.md
54
55
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http_client
55
56
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
56
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.0
57
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.26.1
57
58
  post_install_message:
58
59
  rdoc_options: []
59
60
  require_paths: