opentelemetry-instrumentation-excon 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: a921d5ad6cdca93a94fd432db5cf0d8ef32438912de3ed1d598dc32421b59913
4
- data.tar.gz: dd27126b88bf80c23e3edaf7387dceb85cc5f8127bedc57158572133d551187e
3
+ metadata.gz: 56072eb6e3eb2dc4a87e0d792c504d99c7b8846cdc7a4ec346552b03da298edf
4
+ data.tar.gz: 50015488653810bc9aa10318ff028852f7a470ba2b4b6089491fe16c50767e9b
5
5
  SHA512:
6
- metadata.gz: c138a2b32ca6a3d6c99510a6bdd16407f2451e2e870dc8cf14403628c2268ddb85c3f61d20d3331d868cc76a02c11eaa5b89150714751fc4c76941700b9fc61a
7
- data.tar.gz: ec4d44aea8941398abf1eae8247487c3f1973e6dee70e32c4fa5e3e577e15f9d7e5d1c7e69135f7adece7733db3a8a1ce9bd5546c5c5e19848f6ed6fee8b55ff
6
+ metadata.gz: 0ea4be43d901a377d226b16b71bffcf3fdb30e418019d55757f572ac58496c281099fdfa87827266acc6cacdd654b1148241beaa934947b81850bb78a204eb95
7
+ data.tar.gz: 1fb3ca5e68f13767cf1b432e43c6e3577a2677d4667e8e801264baf5d37a60a29b26f133ca967f6089189beec5d7c634a3f41692abb816f51a93dcfc18850a64
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-excon
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
data/README.md CHANGED
@@ -49,7 +49,6 @@ The `opentelemetry-instrumentation-all` gem is distributed under the Apache 2.0
49
49
  [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
50
50
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
51
51
 
52
-
53
52
  ## HTTP semantic convention stability
54
53
 
55
54
  In the OpenTelemetry ecosystem, HTTP semantic conventions have now reached a stable state. However, the initial Excon instrumentation was introduced before this stability was achieved, which resulted in HTTP attributes being based on an older version of the semantic conventions.
@@ -64,4 +63,4 @@ When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify whic
64
63
 
65
64
  During the transition from old to stable conventions, Excon instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to Excon instrumentation should consider all three patches.
66
65
 
67
- 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/).
@@ -10,8 +10,8 @@ module OpenTelemetry
10
10
  # Utility module for HTTP-related helper methods
11
11
  # @api private
12
12
  module HttpHelper
13
- # Lightweight struct to hold span creation attributes
14
- SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
13
+ # Lightweight struct to hold span creation data
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
@@ -17,29 +17,26 @@ module OpenTelemetry
17
17
  def request_call(datum)
18
18
  return @stack.request_call(datum) if untraced?(datum)
19
19
 
20
- span_data = HttpHelper.span_attrs_for(datum[:method])
20
+ span_data = HttpHelper.span_attrs_for_dup(datum[:method])
21
21
 
22
22
  cleansed_url = OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum))
23
23
  attributes = {
24
24
  OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host],
25
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
26
25
  OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => datum[:scheme],
27
26
  OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => datum[:path],
28
27
  OpenTelemetry::SemanticConventions::Trace::HTTP_URL => cleansed_url,
29
28
  OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => datum[:hostname],
30
29
  OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => datum[:port],
31
- 'http.request.method' => span_data.normalized_method,
32
30
  'url.scheme' => datum[:scheme],
33
31
  'url.path' => datum[:path],
34
32
  'url.full' => cleansed_url,
35
33
  'server.address' => datum[:hostname],
36
34
  'server.port' => datum[:port]
37
35
  }
38
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
39
36
  attributes['url.query'] = datum[:query] if datum[:query]
40
37
  peer_service = Excon::Instrumentation.instance.config[:peer_service]
41
38
  attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
42
- attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
39
+ attributes.merge!(span_data.attributes)
43
40
  span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client)
44
41
  ctx = OpenTelemetry::Trace.context_with_span(span)
45
42
  datum[:otel_span] = span
@@ -17,11 +17,10 @@ module OpenTelemetry
17
17
  def request_call(datum)
18
18
  return @stack.request_call(datum) if untraced?(datum)
19
19
 
20
- span_data = HttpHelper.span_attrs_for(datum[:method], semconv: :old)
20
+ span_data = HttpHelper.span_attrs_for_old(datum[:method])
21
21
 
22
22
  attributes = {
23
23
  OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host],
24
- OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
25
24
  OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => datum[:scheme],
26
25
  OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => datum[:path],
27
26
  OpenTelemetry::SemanticConventions::Trace::HTTP_URL => OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum)),
@@ -30,7 +29,7 @@ module OpenTelemetry
30
29
  }
31
30
  peer_service = Excon::Instrumentation.instance.config[:peer_service]
32
31
  attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
33
- attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
32
+ attributes.merge!(span_data.attributes)
34
33
  span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client)
35
34
  ctx = OpenTelemetry::Trace.context_with_span(span)
36
35
  datum[:otel_span] = span
@@ -17,21 +17,17 @@ module OpenTelemetry
17
17
  def request_call(datum)
18
18
  return @stack.request_call(datum) if untraced?(datum)
19
19
 
20
- span_data = HttpHelper.span_attrs_for(datum[:method])
20
+ span_data = HttpHelper.span_attrs_for_stable(datum[:method])
21
21
 
22
- attributes = {
23
- 'http.request.method' => span_data.normalized_method,
24
- 'url.scheme' => datum[:scheme],
25
- 'url.path' => datum[:path],
26
- 'url.full' => OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum)),
27
- 'server.address' => datum[:hostname],
28
- 'server.port' => datum[:port]
29
- }
30
- attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
22
+ attributes = { 'url.scheme' => datum[:scheme],
23
+ 'url.path' => datum[:path],
24
+ 'url.full' => OpenTelemetry::Common::Utilities.cleanse_url(::Excon::Utils.request_uri(datum)),
25
+ 'server.address' => datum[:hostname],
26
+ 'server.port' => datum[:port] }
31
27
  attributes['url.query'] = datum[:query] if datum[:query]
32
28
  peer_service = Excon::Instrumentation.instance.config[:peer_service]
33
29
  attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service
34
- attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
30
+ attributes.merge!(span_data.attributes)
35
31
  span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client)
36
32
  ctx = OpenTelemetry::Trace.context_with_span(span)
37
33
  datum[:otel_span] = span
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Excon
10
- VERSION = '0.26.1'
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-excon
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
@@ -52,10 +52,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
52
52
  licenses:
53
53
  - Apache-2.0
54
54
  metadata:
55
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-excon/0.26.1/file/CHANGELOG.md
55
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-excon/0.27.0/file/CHANGELOG.md
56
56
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/excon
57
57
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
58
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-excon/0.26.1
58
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-excon/0.27.0
59
59
  post_install_message:
60
60
  rdoc_options: []
61
61
  require_paths: