opentelemetry-instrumentation-net_http 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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +1 -1
- data/lib/opentelemetry/instrumentation/net/http/http_helper.rb +136 -0
- data/lib/opentelemetry/instrumentation/net/http/patches/dup/instrumentation.rb +10 -13
- data/lib/opentelemetry/instrumentation/net/http/patches/old/instrumentation.rb +7 -9
- data/lib/opentelemetry/instrumentation/net/http/patches/stable/instrumentation.rb +7 -8
- data/lib/opentelemetry/instrumentation/net/http/version.rb +1 -1
- data/lib/opentelemetry/instrumentation/net/http.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af57eff25e83e807b9fce58534f7354a8da730eeb796e37304e4fcfff10aacf8
|
|
4
|
+
data.tar.gz: e05dab69206fd8a7eadee713bbc057c423b3908f848abf336d52ca974aab119b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f28c788929d2d2b2330291598b1116586e0ae5f692592ccff42b212cc948c035bc65d639d72391e990881a5326987d74441efea816f64fc82fde1e1ca9ae5cba
|
|
7
|
+
data.tar.gz: 96ec477a7341ac52207adfd0a14b8bc20ebd64445f84b7cbb295d10a9b61be0af1e93a8983792e18cc8112c9b933151b25bc52f500abe01c320406c0384a29f1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Release History: opentelemetry-instrumentation-net_http
|
|
2
2
|
|
|
3
|
+
### v0.27.0 / 2026-01-13
|
|
4
|
+
|
|
5
|
+
* ADDED: HTTP Client Semconv v1.17 Span Naming
|
|
6
|
+
|
|
7
|
+
### v0.26.1 / 2025-11-25
|
|
8
|
+
|
|
9
|
+
* FIXED: Update support for unknown HTTP methods to match semantic conventions
|
|
10
|
+
|
|
3
11
|
### v0.26.0 / 2025-10-22
|
|
4
12
|
|
|
5
13
|
* BREAKING CHANGE: Min Ruby Version 3.2
|
|
@@ -89,7 +97,7 @@
|
|
|
89
97
|
|
|
90
98
|
### v0.19.4 / 2022-02-02
|
|
91
99
|
|
|
92
|
-
* FIXED:
|
|
100
|
+
* FIXED: Client Context attrs overwrite in net::http
|
|
93
101
|
* FIXED: Excessive hash creation on context attr merging
|
|
94
102
|
|
|
95
103
|
### v0.19.3 / 2021-12-01
|
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, Net::HTTP instrumentation code comes in three patch versions: `dup`, `old`, and `stable`. These versions are identical except for the attributes they send. Any changes to Net::HTTP 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/).
|
|
@@ -0,0 +1,136 @@
|
|
|
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 Net
|
|
10
|
+
module HTTP
|
|
11
|
+
# Utility module for HTTP-related helper methods
|
|
12
|
+
# @api private
|
|
13
|
+
module HttpHelper
|
|
14
|
+
# Lightweight struct to hold span creation attributes
|
|
15
|
+
SpanCreationAttributes = Struct.new(:span_name, :attributes, keyword_init: true)
|
|
16
|
+
|
|
17
|
+
# Pre-computed mapping to avoid string allocations during normalization
|
|
18
|
+
METHOD_CACHE = {
|
|
19
|
+
'CONNECT' => 'CONNECT',
|
|
20
|
+
'DELETE' => 'DELETE',
|
|
21
|
+
'GET' => 'GET',
|
|
22
|
+
'HEAD' => 'HEAD',
|
|
23
|
+
'OPTIONS' => 'OPTIONS',
|
|
24
|
+
'PATCH' => 'PATCH',
|
|
25
|
+
'POST' => 'POST',
|
|
26
|
+
'PUT' => 'PUT',
|
|
27
|
+
'TRACE' => 'TRACE',
|
|
28
|
+
'connect' => 'CONNECT',
|
|
29
|
+
'delete' => 'DELETE',
|
|
30
|
+
'get' => 'GET',
|
|
31
|
+
'head' => 'HEAD',
|
|
32
|
+
'options' => 'OPTIONS',
|
|
33
|
+
'patch' => 'PATCH',
|
|
34
|
+
'post' => 'POST',
|
|
35
|
+
'put' => 'PUT',
|
|
36
|
+
'trace' => 'TRACE',
|
|
37
|
+
:connect => 'CONNECT',
|
|
38
|
+
:delete => 'DELETE',
|
|
39
|
+
:get => 'GET',
|
|
40
|
+
:head => 'HEAD',
|
|
41
|
+
:options => 'OPTIONS',
|
|
42
|
+
:patch => 'PATCH',
|
|
43
|
+
:post => 'POST',
|
|
44
|
+
:put => 'PUT',
|
|
45
|
+
:trace => 'TRACE'
|
|
46
|
+
}.freeze
|
|
47
|
+
|
|
48
|
+
private_constant :METHOD_CACHE
|
|
49
|
+
|
|
50
|
+
OLD_SPAN_NAMES_BY_METHOD = METHOD_CACHE.values.uniq.each_with_object({}) do |method, hash|
|
|
51
|
+
hash[method] = "HTTP #{method}"
|
|
52
|
+
end.freeze
|
|
53
|
+
|
|
54
|
+
private_constant :OLD_SPAN_NAMES_BY_METHOD
|
|
55
|
+
|
|
56
|
+
# Prepares span data using old semantic conventions
|
|
57
|
+
# @param method [String, Symbol] The HTTP method
|
|
58
|
+
# @return [SpanCreationAttributes] struct containing span_name and attributes hash
|
|
59
|
+
def self.span_attrs_for_old(method)
|
|
60
|
+
client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
|
|
61
|
+
normalized = METHOD_CACHE[method]
|
|
62
|
+
attributes = client_context_attrs.dup
|
|
63
|
+
|
|
64
|
+
# Determine base span name and method value
|
|
65
|
+
if normalized
|
|
66
|
+
span_name = OLD_SPAN_NAMES_BY_METHOD[normalized]
|
|
67
|
+
method_value = normalized
|
|
68
|
+
else
|
|
69
|
+
span_name = 'HTTP'
|
|
70
|
+
method_value = '_OTHER'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
attributes['http.method'] ||= method_value
|
|
74
|
+
|
|
75
|
+
SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Prepares span data using stable semantic conventions
|
|
79
|
+
# @param method [String, Symbol] The HTTP method
|
|
80
|
+
# @return [SpanCreationAttributes] struct containing span_name and attributes hash
|
|
81
|
+
def self.span_attrs_for_stable(method)
|
|
82
|
+
client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
|
|
83
|
+
url_template = client_context_attrs['url.template']
|
|
84
|
+
normalized = METHOD_CACHE[method]
|
|
85
|
+
attributes = client_context_attrs.dup
|
|
86
|
+
|
|
87
|
+
# Determine base span name and method value
|
|
88
|
+
if normalized
|
|
89
|
+
base_name = normalized
|
|
90
|
+
method_value = normalized
|
|
91
|
+
original = nil
|
|
92
|
+
else
|
|
93
|
+
base_name = 'HTTP'
|
|
94
|
+
method_value = '_OTHER'
|
|
95
|
+
original = method.to_s
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
span_name = url_template ? "#{base_name} #{url_template}" : base_name
|
|
99
|
+
attributes['http.request.method'] ||= method_value
|
|
100
|
+
attributes['http.request.method_original'] ||= original if original
|
|
101
|
+
|
|
102
|
+
SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Prepares span data using both old and stable semantic conventions
|
|
106
|
+
# @param method [String, Symbol] The HTTP method
|
|
107
|
+
# @return [SpanCreationAttributes] struct containing span_name and attributes hash
|
|
108
|
+
def self.span_attrs_for_dup(method)
|
|
109
|
+
client_context_attrs = OpenTelemetry::Common::HTTP::ClientContext.attributes
|
|
110
|
+
url_template = client_context_attrs['url.template']
|
|
111
|
+
normalized = METHOD_CACHE[method]
|
|
112
|
+
attributes = client_context_attrs.dup
|
|
113
|
+
|
|
114
|
+
# Determine base span name and method value
|
|
115
|
+
if normalized
|
|
116
|
+
base_name = normalized
|
|
117
|
+
method_value = normalized
|
|
118
|
+
original = nil
|
|
119
|
+
else
|
|
120
|
+
base_name = 'HTTP'
|
|
121
|
+
method_value = '_OTHER'
|
|
122
|
+
original = method.to_s
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
span_name = url_template ? "#{base_name} #{url_template}" : base_name
|
|
126
|
+
attributes['http.method'] ||= method_value
|
|
127
|
+
attributes['http.request.method'] ||= method_value
|
|
128
|
+
attributes['http.request.method_original'] ||= original if original
|
|
129
|
+
|
|
130
|
+
SpanCreationAttributes.new(span_name: span_name, attributes: attributes)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -23,25 +23,22 @@ module OpenTelemetry
|
|
|
23
23
|
|
|
24
24
|
return super if untraced?
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'server.address' => @address,
|
|
35
|
-
'server.port' => @port
|
|
36
|
-
}
|
|
26
|
+
span_data = HttpHelper.span_attrs_for_dup(req.method)
|
|
27
|
+
|
|
28
|
+
attributes = { OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
|
|
29
|
+
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
|
|
30
|
+
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
|
|
31
|
+
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port, 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
|
|
32
|
+
'server.address' => @address,
|
|
33
|
+
'server.port' => @port }
|
|
37
34
|
path, query = split_path_and_query(req.path)
|
|
38
35
|
attributes['url.path'] = path
|
|
39
36
|
attributes['url.query'] = query if query
|
|
40
37
|
|
|
41
|
-
attributes.merge!(
|
|
38
|
+
attributes.merge!(span_data.attributes)
|
|
42
39
|
|
|
43
40
|
tracer.in_span(
|
|
44
|
-
|
|
41
|
+
span_data.span_name,
|
|
45
42
|
attributes: attributes,
|
|
46
43
|
kind: :client
|
|
47
44
|
) do |span|
|
|
@@ -12,7 +12,6 @@ module OpenTelemetry
|
|
|
12
12
|
module Old
|
|
13
13
|
# Module to prepend to Net::HTTP for instrumentation
|
|
14
14
|
module Instrumentation
|
|
15
|
-
HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" }
|
|
16
15
|
USE_SSL_TO_SCHEME = { false => 'http', true => 'https' }.freeze
|
|
17
16
|
|
|
18
17
|
# Constant for the HTTP status range
|
|
@@ -24,16 +23,15 @@ module OpenTelemetry
|
|
|
24
23
|
|
|
25
24
|
return super if untraced?
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
26
|
+
span_data = HttpHelper.span_attrs_for_old(req.method)
|
|
27
|
+
|
|
28
|
+
attributes = { OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?],
|
|
29
|
+
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path,
|
|
30
|
+
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address,
|
|
31
|
+
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port }.merge!(span_data.attributes)
|
|
34
32
|
|
|
35
33
|
tracer.in_span(
|
|
36
|
-
|
|
34
|
+
span_data.span_name,
|
|
37
35
|
attributes: attributes,
|
|
38
36
|
kind: :client
|
|
39
37
|
) do |span|
|
|
@@ -23,20 +23,19 @@ module OpenTelemetry
|
|
|
23
23
|
|
|
24
24
|
return super if untraced?
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
26
|
+
span_data = HttpHelper.span_attrs_for_stable(req.method)
|
|
27
|
+
|
|
28
|
+
attributes = { 'url.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
|
|
29
|
+
'server.address' => @address,
|
|
30
|
+
'server.port' => @port }
|
|
32
31
|
path, query = split_path_and_query(req.path)
|
|
33
32
|
attributes['url.path'] = path
|
|
34
33
|
attributes['url.query'] = query if query
|
|
35
34
|
|
|
36
|
-
attributes.merge!(
|
|
35
|
+
attributes.merge!(span_data.attributes)
|
|
37
36
|
|
|
38
37
|
tracer.in_span(
|
|
39
|
-
|
|
38
|
+
span_data.span_name,
|
|
40
39
|
attributes: attributes,
|
|
41
40
|
kind: :client
|
|
42
41
|
) do |span|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opentelemetry-instrumentation-net_http
|
|
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
|
|
@@ -38,6 +38,7 @@ files:
|
|
|
38
38
|
- lib/opentelemetry-instrumentation-net_http.rb
|
|
39
39
|
- lib/opentelemetry/instrumentation.rb
|
|
40
40
|
- lib/opentelemetry/instrumentation/net/http.rb
|
|
41
|
+
- lib/opentelemetry/instrumentation/net/http/http_helper.rb
|
|
41
42
|
- lib/opentelemetry/instrumentation/net/http/instrumentation.rb
|
|
42
43
|
- lib/opentelemetry/instrumentation/net/http/patches/dup/instrumentation.rb
|
|
43
44
|
- lib/opentelemetry/instrumentation/net/http/patches/old/instrumentation.rb
|
|
@@ -47,10 +48,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
|
47
48
|
licenses:
|
|
48
49
|
- Apache-2.0
|
|
49
50
|
metadata:
|
|
50
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.
|
|
51
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.27.0/file/CHANGELOG.md
|
|
51
52
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/net_http
|
|
52
53
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
53
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.
|
|
54
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-net_http/0.27.0
|
|
54
55
|
post_install_message:
|
|
55
56
|
rdoc_options: []
|
|
56
57
|
require_paths:
|