opentelemetry-instrumentation-ethon 0.26.0 → 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: 87daf04ee19dc0418bd8a3299ca44a7d2f3f84f9487fadce2a1e8c46b1f6dce5
4
- data.tar.gz: 34895ac3926d8c6f6d5aac9782987d9cd3ce1efde6e9b68eadf96df3c8753901
3
+ metadata.gz: a10aefb2b3c503be55bf54ddc3c2d0fe69d0d143106d03abc659f45a5426c878
4
+ data.tar.gz: 1b4307016331351fe8f8be7320a6636dece386695b6ecfcc82b8903f05ce92df
5
5
  SHA512:
6
- metadata.gz: 8b74299d09a7ad578d7ac3a3d67f4364b670e10ac674545da107386eb713461b411b8594a8f4875cd36f98e8d906293bd10ce4b34dfeb7b7abccc74b8be33240
7
- data.tar.gz: 58263b2e3e93e5d9f441d7c5f36e1ed560f3308d82cf0c8db90ae502e224fcc4aba7b2871c1938ae44394d1323400612bab308121fa755a71a012420c9ff0a61
6
+ metadata.gz: e5fb931f0f11d03e200f57dbfad551afc304acd35e12cd86a28493f81c371db33fe9366f21e2a053a9564cdf664b0db838ff0f4b5a3c10ef5fecd1cedd871a04
7
+ data.tar.gz: db64e4a70ad09bb043d01c95d7642d096e134e03baf8334d3fd40d90e31d8f6389b844df56259d305d2f573f47b228ad9e5164c3db6b7cfde6147041b6c173d4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-ethon
2
2
 
3
+ ### v0.27.0 / 2026-01-13
4
+
5
+ * ADDED: HTTP Client Semconv v1.17 Span Naming
6
+
3
7
  ### v0.26.0 / 2025-11-26
4
8
 
5
9
  * BREAKING CHANGE: Update Ethon span name when unknown method
data/README.md CHANGED
@@ -44,7 +44,7 @@ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special int
44
44
 
45
45
  The `opentelemetry-instrumentation-all` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
46
46
 
47
- [ethon-home]:https://github.com/typhoeus/ethon
47
+ [ethon-home]: https://github.com/typhoeus/ethon
48
48
  [bundler-home]: https://bundler.io
49
49
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
50
50
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
@@ -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, Ethon instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to Ethon 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/).
@@ -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, keyword_init: true)
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.each_with_object({}) do |method, hash|
50
+ hash[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
@@ -68,7 +68,7 @@ module OpenTelemetry
68
68
  end
69
69
 
70
70
  def otel_before_request
71
- span_data = HttpHelper.span_attrs_for(@otel_method)
71
+ span_data = HttpHelper.span_attrs_for_dup(@otel_method)
72
72
 
73
73
  @otel_span = tracer.start_span(
74
74
  span_data.span_name,
@@ -90,11 +90,7 @@ module OpenTelemetry
90
90
  private
91
91
 
92
92
  def span_creation_attributes(span_data)
93
- instrumentation_attrs = {
94
- 'http.method' => span_data.normalized_method,
95
- 'http.request.method' => span_data.normalized_method
96
- }
97
- instrumentation_attrs['http.request.method_original'] = span_data.original_method if span_data.original_method
93
+ instrumentation_attrs = {}
98
94
 
99
95
  uri = _otel_cleanse_uri(url)
100
96
  if uri
@@ -106,9 +102,7 @@ module OpenTelemetry
106
102
 
107
103
  config = Ethon::Instrumentation.instance.config
108
104
  instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
109
- instrumentation_attrs.merge!(
110
- OpenTelemetry::Common::HTTP::ClientContext.attributes
111
- )
105
+ instrumentation_attrs.merge!(span_data.attributes)
112
106
  end
113
107
 
114
108
  # Returns a URL string with userinfo removed.
@@ -67,7 +67,7 @@ module OpenTelemetry
67
67
  end
68
68
 
69
69
  def otel_before_request
70
- span_data = HttpHelper.span_attrs_for(@otel_method, semconv: :old)
70
+ span_data = HttpHelper.span_attrs_for_old(@otel_method)
71
71
 
72
72
  @otel_span = tracer.start_span(
73
73
  span_data.span_name,
@@ -89,9 +89,7 @@ module OpenTelemetry
89
89
  private
90
90
 
91
91
  def span_creation_attributes(span_data)
92
- instrumentation_attrs = {
93
- 'http.method' => span_data.normalized_method
94
- }
92
+ instrumentation_attrs = {}
95
93
 
96
94
  uri = _otel_cleanse_uri(url)
97
95
  if uri
@@ -101,9 +99,7 @@ module OpenTelemetry
101
99
 
102
100
  config = Ethon::Instrumentation.instance.config
103
101
  instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
104
- instrumentation_attrs.merge!(
105
- OpenTelemetry::Common::HTTP::ClientContext.attributes
106
- )
102
+ instrumentation_attrs.merge!(span_data.attributes)
107
103
  end
108
104
 
109
105
  # Returns a URL string with userinfo removed.
@@ -67,7 +67,7 @@ module OpenTelemetry
67
67
  end
68
68
 
69
69
  def otel_before_request
70
- span_data = HttpHelper.span_attrs_for(@otel_method)
70
+ span_data = HttpHelper.span_attrs_for_stable(@otel_method)
71
71
 
72
72
  @otel_span = tracer.start_span(
73
73
  span_data.span_name,
@@ -89,10 +89,7 @@ module OpenTelemetry
89
89
  private
90
90
 
91
91
  def span_creation_attributes(span_data)
92
- instrumentation_attrs = {
93
- 'http.request.method' => span_data.normalized_method
94
- }
95
- instrumentation_attrs['http.request.method_original'] = span_data.original_method if span_data.original_method
92
+ instrumentation_attrs = {}
96
93
 
97
94
  uri = _otel_cleanse_uri(url)
98
95
  if uri
@@ -102,9 +99,7 @@ module OpenTelemetry
102
99
 
103
100
  config = Ethon::Instrumentation.instance.config
104
101
  instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]
105
- instrumentation_attrs.merge!(
106
- OpenTelemetry::Common::HTTP::ClientContext.attributes
107
- )
102
+ instrumentation_attrs.merge!(span_data.attributes)
108
103
  end
109
104
 
110
105
  # Returns a URL string with userinfo removed.
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Ethon
10
- VERSION = '0.26.0'
10
+ VERSION = '0.27.0'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
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-26 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
@@ -49,10 +49,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
49
49
  licenses:
50
50
  - Apache-2.0
51
51
  metadata:
52
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-ethon/0.26.0/file/CHANGELOG.md
52
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-ethon/0.27.0/file/CHANGELOG.md
53
53
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/ethon
54
54
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
55
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-ethon/0.26.0
55
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-ethon/0.27.0
56
56
  post_install_message:
57
57
  rdoc_options: []
58
58
  require_paths: