opentelemetry-instrumentation-http 0.27.1 → 0.28.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 +5 -1
- data/lib/opentelemetry/instrumentation/http/http_helper.rb +77 -29
- data/lib/opentelemetry/instrumentation/http/patches/dup/client.rb +5 -6
- data/lib/opentelemetry/instrumentation/http/patches/old/client.rb +5 -4
- data/lib/opentelemetry/instrumentation/http/patches/stable/client.rb +10 -12
- data/lib/opentelemetry/instrumentation/http/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: feb5b23c7a36a0ea90576209babda48b3bc6c9df66e40c520576513f4ce1fe76
|
|
4
|
+
data.tar.gz: d15b180dbb268b10ba557deb9c5b5805dfb9f3046a240f8a729e12f07a78f642
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6304c10c4524e6864305b8b4eaa5d0a00d0517d677d58fe2bcb5a0319828165c0d574c8b6c8d7551896369298ecb1ce028967d7e93558b9b68a8c55622c7a98e
|
|
7
|
+
data.tar.gz: 99361f4657967d1b60c6e3c4a77b5f6a115f852d1573d79f57e0e24e37370d8507b64e57f815aa90d610e968f60ad0e68a2527041d0fd822caf347881bad3ac3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Release History: opentelemetry-instrumentation-http
|
|
2
2
|
|
|
3
|
+
### v0.28.0 / 2026-01-13
|
|
4
|
+
|
|
5
|
+
* ADDED: HTTP Client Semconv v1.17 Span Naming
|
|
6
|
+
|
|
3
7
|
### v0.27.1 / 2025-11-25
|
|
4
8
|
|
|
5
9
|
* FIXED: Update support for unknown HTTP methods to match semantic conventions
|
|
@@ -113,7 +117,7 @@
|
|
|
113
117
|
|
|
114
118
|
### v0.16.2 / 2021-03-29
|
|
115
119
|
|
|
116
|
-
* FIXED: HTTP
|
|
120
|
+
* FIXED: HTTP Instrumentation should check for gem presence
|
|
117
121
|
|
|
118
122
|
### v0.16.1 / 2021-03-25
|
|
119
123
|
|
|
@@ -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
|
|
@@ -16,30 +16,27 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
-
span_data = HttpHelper.
|
|
19
|
+
span_data = HttpHelper.span_attrs_for_dup(req.verb)
|
|
20
20
|
|
|
21
21
|
uri = req.uri
|
|
22
22
|
span_name = create_span_name(span_data, uri.path)
|
|
23
23
|
|
|
24
24
|
attributes = {
|
|
25
25
|
# old semconv
|
|
26
|
-
'http.method' => span_data.normalized_method,
|
|
27
26
|
'http.scheme' => uri.scheme,
|
|
28
27
|
'http.target' => uri.path,
|
|
29
28
|
'http.url' => "#{uri.scheme}://#{uri.host}",
|
|
30
29
|
'net.peer.name' => uri.host,
|
|
31
30
|
'net.peer.port' => uri.port,
|
|
32
31
|
# stable semconv
|
|
33
|
-
'http.request.method' => span_data.normalized_method,
|
|
34
32
|
'url.scheme' => uri.scheme,
|
|
35
33
|
'url.path' => uri.path,
|
|
36
34
|
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
37
35
|
'server.address' => uri.host,
|
|
38
36
|
'server.port' => uri.port
|
|
39
37
|
}
|
|
40
|
-
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
41
38
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
42
|
-
attributes.merge!(
|
|
39
|
+
attributes.merge!(span_data.attributes)
|
|
43
40
|
|
|
44
41
|
tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
|
|
45
42
|
OpenTelemetry.propagation.inject(req.headers)
|
|
@@ -68,7 +65,9 @@ module OpenTelemetry
|
|
|
68
65
|
default_span_name = span_data.span_name
|
|
69
66
|
|
|
70
67
|
if (implementation = config[:span_name_formatter])
|
|
71
|
-
|
|
68
|
+
# Extract the HTTP method from attributes (old semconv key)
|
|
69
|
+
http_method = span_data.attributes['http.method'] || span_data.attributes['http.request.method']
|
|
70
|
+
updated_span_name = implementation.call(http_method, request_path)
|
|
72
71
|
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
73
72
|
else
|
|
74
73
|
default_span_name
|
|
@@ -16,19 +16,18 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
-
span_data = HttpHelper.
|
|
19
|
+
span_data = HttpHelper.span_attrs_for_old(req.verb)
|
|
20
20
|
|
|
21
21
|
uri = req.uri
|
|
22
22
|
span_name = create_span_name(span_data, uri.path)
|
|
23
23
|
|
|
24
24
|
attributes = {
|
|
25
|
-
'http.method' => span_data.normalized_method,
|
|
26
25
|
'http.scheme' => uri.scheme,
|
|
27
26
|
'http.target' => uri.path,
|
|
28
27
|
'http.url' => "#{uri.scheme}://#{uri.host}",
|
|
29
28
|
'net.peer.name' => uri.host,
|
|
30
29
|
'net.peer.port' => uri.port
|
|
31
|
-
}.merge!(
|
|
30
|
+
}.merge!(span_data.attributes)
|
|
32
31
|
|
|
33
32
|
tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
|
|
34
33
|
OpenTelemetry.propagation.inject(req.headers)
|
|
@@ -56,7 +55,9 @@ module OpenTelemetry
|
|
|
56
55
|
default_span_name = span_data.span_name
|
|
57
56
|
|
|
58
57
|
if (implementation = config[:span_name_formatter])
|
|
59
|
-
|
|
58
|
+
# Extract the HTTP method from attributes
|
|
59
|
+
http_method = span_data.attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD]
|
|
60
|
+
updated_span_name = implementation.call(http_method, request_path)
|
|
60
61
|
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
61
62
|
else
|
|
62
63
|
default_span_name
|
|
@@ -16,22 +16,18 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
-
span_data = HttpHelper.
|
|
19
|
+
span_data = HttpHelper.span_attrs_for_stable(req.verb)
|
|
20
20
|
|
|
21
21
|
uri = req.uri
|
|
22
22
|
span_name = create_span_name(span_data, uri.path)
|
|
23
23
|
|
|
24
|
-
attributes = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'server.address' => uri.host,
|
|
30
|
-
'server.port' => uri.port
|
|
31
|
-
}
|
|
32
|
-
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
24
|
+
attributes = { 'url.scheme' => uri.scheme,
|
|
25
|
+
'url.path' => uri.path,
|
|
26
|
+
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
27
|
+
'server.address' => uri.host,
|
|
28
|
+
'server.port' => uri.port }
|
|
33
29
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
34
|
-
attributes.merge!(
|
|
30
|
+
attributes.merge!(span_data.attributes)
|
|
35
31
|
|
|
36
32
|
tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
|
|
37
33
|
OpenTelemetry.propagation.inject(req.headers)
|
|
@@ -59,7 +55,9 @@ module OpenTelemetry
|
|
|
59
55
|
default_span_name = span_data.span_name
|
|
60
56
|
|
|
61
57
|
if (implementation = config[:span_name_formatter])
|
|
62
|
-
|
|
58
|
+
# Extract the HTTP method from attributes
|
|
59
|
+
http_method = span_data.attributes['http.request.method']
|
|
60
|
+
updated_span_name = implementation.call(http_method, request_path)
|
|
63
61
|
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
64
62
|
else
|
|
65
63
|
default_span_name
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opentelemetry-instrumentation-http
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.28.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/0.
|
|
54
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.28.0/file/CHANGELOG.md
|
|
55
55
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
|
|
56
56
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
57
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.
|
|
57
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.28.0
|
|
58
58
|
post_install_message:
|
|
59
59
|
rdoc_options: []
|
|
60
60
|
require_paths:
|