opentelemetry-instrumentation-http_client 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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/opentelemetry/instrumentation/http_client/http_helper.rb +77 -29
- data/lib/opentelemetry/instrumentation/http_client/patches/dup/client.rb +2 -5
- data/lib/opentelemetry/instrumentation/http_client/patches/old/client.rb +3 -3
- data/lib/opentelemetry/instrumentation/http_client/patches/stable/client.rb +7 -10
- data/lib/opentelemetry/instrumentation/http_client/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97fed59fe7e430410a9353509988107cc0504e292ddfe4c33c92725ce389c612
|
|
4
|
+
data.tar.gz: 44d7e50ff1ccd8100628e9885c1d2a044407f6e8c2f6f267ae9da2d765e7e28a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8dfca712f29151b379321cc97a7e9cfd247a6e703306ef8acfdd0d467703e9374c46733a24c7e28246bb1f7e9f21490cb7856f8cf2dbda0f4a803419685defa9
|
|
7
|
+
data.tar.gz: cd4feb2873c2be4d263567efb437ec42871df5b053980ee88b4544c9e909833dee64aaa16e44374080bfd8d1a7eb5dca9799aa7a1bd3bc44c354b5731a3a827d
|
data/CHANGELOG.md
CHANGED
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, HttpClient instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to HttpClient 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, :
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 :
|
|
53
|
+
private_constant :OLD_SPAN_NAMES_BY_METHOD
|
|
61
54
|
|
|
62
|
-
# Prepares
|
|
55
|
+
# Prepares span data using old semantic conventions
|
|
63
56
|
# @param method [String, Symbol] The HTTP method
|
|
64
|
-
# @
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
normalized_method: normalized,
|
|
73
|
-
original_method: nil
|
|
74
|
-
)
|
|
88
|
+
base_name = normalized
|
|
89
|
+
method_value = normalized
|
|
90
|
+
original = nil
|
|
75
91
|
else
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
@@ -20,25 +20,22 @@ 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.
|
|
23
|
+
span_data = HttpHelper.span_attrs_for_dup(request_method)
|
|
24
24
|
|
|
25
25
|
attributes = {
|
|
26
|
-
'http.method' => span_data.normalized_method,
|
|
27
26
|
'http.scheme' => uri.scheme,
|
|
28
27
|
'http.target' => uri.path,
|
|
29
28
|
'http.url' => url,
|
|
30
29
|
'net.peer.name' => uri.host,
|
|
31
30
|
'net.peer.port' => uri.port,
|
|
32
31
|
# stable semantic conventions
|
|
33
|
-
'http.request.method' => span_data.normalized_method,
|
|
34
32
|
'url.scheme' => uri.scheme,
|
|
35
33
|
'url.path' => uri.path,
|
|
36
34
|
'url.full' => url,
|
|
37
35
|
'server.address' => uri.host,
|
|
38
36
|
'server.port' => uri.port
|
|
39
|
-
}.merge!(
|
|
37
|
+
}.merge!(span_data.attributes)
|
|
40
38
|
|
|
41
|
-
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
42
39
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
43
40
|
|
|
44
41
|
tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
|
|
@@ -20,16 +20,16 @@ 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
|
-
|
|
23
|
+
|
|
24
|
+
span_data = HttpHelper.span_attrs_for_old(request_method)
|
|
24
25
|
|
|
25
26
|
attributes = {
|
|
26
|
-
'http.method' => span_data.normalized_method,
|
|
27
27
|
'http.scheme' => uri.scheme,
|
|
28
28
|
'http.target' => uri.path,
|
|
29
29
|
'http.url' => url,
|
|
30
30
|
'net.peer.name' => uri.host,
|
|
31
31
|
'net.peer.port' => uri.port
|
|
32
|
-
}.merge!(
|
|
32
|
+
}.merge!(span_data.attributes)
|
|
33
33
|
|
|
34
34
|
tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
|
|
35
35
|
OpenTelemetry.propagation.inject(req.header)
|
|
@@ -20,18 +20,15 @@ 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)
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
24
|
+
span_data = HttpHelper.span_attrs_for_stable(request_method)
|
|
25
|
+
|
|
26
|
+
attributes = { 'url.scheme' => uri.scheme,
|
|
27
|
+
'url.path' => uri.path,
|
|
28
|
+
'url.full' => url,
|
|
29
|
+
'server.address' => uri.host,
|
|
30
|
+
'server.port' => uri.port }.merge!(span_data.attributes)
|
|
33
31
|
|
|
34
|
-
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
35
32
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
36
33
|
|
|
37
34
|
tracer.in_span(span_data.span_name, attributes: attributes, kind: :client) do |span|
|
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.
|
|
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:
|
|
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
|
|
@@ -51,10 +51,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
|
51
51
|
licenses:
|
|
52
52
|
- Apache-2.0
|
|
53
53
|
metadata:
|
|
54
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.
|
|
54
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.27.0/file/CHANGELOG.md
|
|
55
55
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http_client
|
|
56
56
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
57
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.
|
|
57
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.27.0
|
|
58
58
|
post_install_message:
|
|
59
59
|
rdoc_options: []
|
|
60
60
|
require_paths:
|