opentelemetry-instrumentation-http 0.27.0 → 0.27.1
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/lib/opentelemetry/instrumentation/http/http_helper.rb +86 -0
- data/lib/opentelemetry/instrumentation/http/patches/dup/client.rb +13 -9
- data/lib/opentelemetry/instrumentation/http/patches/old/client.rb +11 -8
- data/lib/opentelemetry/instrumentation/http/patches/stable/client.rb +12 -8
- data/lib/opentelemetry/instrumentation/http/version.rb +1 -1
- data/lib/opentelemetry/instrumentation/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: 850cb2d0a9d8d18cf00cade03d86e379a2338f626a0f1468e32b37c186de0869
|
|
4
|
+
data.tar.gz: d89c15de55426a730fdaef82e1b8212fa20981b645b9985f66712ceff7cab2b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 676dd8c1071ed0c9f0927c6def794f71637919a3303be4df314ebfe2cdb8037f04e64c5ccbdc649326f51c920437714cd504699a59e26dbfeb33569aed5172e0
|
|
7
|
+
data.tar.gz: a681dc2912300b21a16e1d7d069cf8e35eb3f9899917e87f89522f15e7b949de8f963bb894eb5efd887cc0a2cd8120077b25b3c29dc125dd0beffd7a150e3bb8
|
data/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
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 HTTP
|
|
10
|
+
# Module for normalizing HTTP methods
|
|
11
|
+
# @api private
|
|
12
|
+
module HttpHelper
|
|
13
|
+
# Lightweight struct to hold span creation attributes
|
|
14
|
+
SpanCreationAttributes = Struct.new(:span_name, :normalized_method, :original_method, keyword_init: true)
|
|
15
|
+
|
|
16
|
+
# Pre-computed mapping to avoid string allocations during normalization
|
|
17
|
+
METHOD_CACHE = {
|
|
18
|
+
'CONNECT' => 'CONNECT',
|
|
19
|
+
'DELETE' => 'DELETE',
|
|
20
|
+
'GET' => 'GET',
|
|
21
|
+
'HEAD' => 'HEAD',
|
|
22
|
+
'OPTIONS' => 'OPTIONS',
|
|
23
|
+
'PATCH' => 'PATCH',
|
|
24
|
+
'POST' => 'POST',
|
|
25
|
+
'PUT' => 'PUT',
|
|
26
|
+
'TRACE' => 'TRACE',
|
|
27
|
+
'connect' => 'CONNECT',
|
|
28
|
+
'delete' => 'DELETE',
|
|
29
|
+
'get' => 'GET',
|
|
30
|
+
'head' => 'HEAD',
|
|
31
|
+
'options' => 'OPTIONS',
|
|
32
|
+
'patch' => 'PATCH',
|
|
33
|
+
'post' => 'POST',
|
|
34
|
+
'put' => 'PUT',
|
|
35
|
+
'trace' => 'TRACE',
|
|
36
|
+
:connect => 'CONNECT',
|
|
37
|
+
:delete => 'DELETE',
|
|
38
|
+
:get => 'GET',
|
|
39
|
+
:head => 'HEAD',
|
|
40
|
+
:options => 'OPTIONS',
|
|
41
|
+
:patch => 'PATCH',
|
|
42
|
+
:post => 'POST',
|
|
43
|
+
:put => 'PUT',
|
|
44
|
+
:trace => 'TRACE'
|
|
45
|
+
}.freeze
|
|
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
|
|
59
|
+
|
|
60
|
+
private_constant :METHOD_CACHE, :OLD_SPAN_NAMES
|
|
61
|
+
|
|
62
|
+
# Prepares all span data for the specified semantic convention in a single call
|
|
63
|
+
# @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)
|
|
67
|
+
normalized = METHOD_CACHE[method]
|
|
68
|
+
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
|
+
)
|
|
75
|
+
else
|
|
76
|
+
SpanCreationAttributes.new(
|
|
77
|
+
span_name: 'HTTP',
|
|
78
|
+
normalized_method: '_OTHER',
|
|
79
|
+
original_method: method.to_s
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -16,26 +16,28 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
+
span_data = HttpHelper.span_attrs_for(req.verb)
|
|
20
|
+
|
|
19
21
|
uri = req.uri
|
|
20
|
-
|
|
21
|
-
span_name = create_request_span_name(request_method, uri.path)
|
|
22
|
+
span_name = create_span_name(span_data, uri.path)
|
|
22
23
|
|
|
23
24
|
attributes = {
|
|
24
25
|
# old semconv
|
|
25
|
-
'http.method' =>
|
|
26
|
+
'http.method' => span_data.normalized_method,
|
|
26
27
|
'http.scheme' => uri.scheme,
|
|
27
28
|
'http.target' => uri.path,
|
|
28
29
|
'http.url' => "#{uri.scheme}://#{uri.host}",
|
|
29
30
|
'net.peer.name' => uri.host,
|
|
30
31
|
'net.peer.port' => uri.port,
|
|
31
32
|
# stable semconv
|
|
32
|
-
'http.request.method' =>
|
|
33
|
+
'http.request.method' => span_data.normalized_method,
|
|
33
34
|
'url.scheme' => uri.scheme,
|
|
34
35
|
'url.path' => uri.path,
|
|
35
36
|
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
36
37
|
'server.address' => uri.host,
|
|
37
38
|
'server.port' => uri.port
|
|
38
39
|
}
|
|
40
|
+
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
39
41
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
40
42
|
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
41
43
|
|
|
@@ -62,15 +64,17 @@ module OpenTelemetry
|
|
|
62
64
|
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
|
63
65
|
end
|
|
64
66
|
|
|
65
|
-
def
|
|
67
|
+
def create_span_name(span_data, request_path)
|
|
68
|
+
default_span_name = span_data.span_name
|
|
69
|
+
|
|
66
70
|
if (implementation = config[:span_name_formatter])
|
|
67
|
-
updated_span_name = implementation.call(
|
|
68
|
-
updated_span_name.is_a?(String) ? updated_span_name :
|
|
71
|
+
updated_span_name = implementation.call(span_data.normalized_method, request_path)
|
|
72
|
+
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
69
73
|
else
|
|
70
|
-
|
|
74
|
+
default_span_name
|
|
71
75
|
end
|
|
72
76
|
rescue StandardError
|
|
73
|
-
|
|
77
|
+
default_span_name
|
|
74
78
|
end
|
|
75
79
|
|
|
76
80
|
def tracer
|
|
@@ -16,12 +16,13 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
+
span_data = HttpHelper.span_attrs_for(req.verb, semconv: :old)
|
|
20
|
+
|
|
19
21
|
uri = req.uri
|
|
20
|
-
|
|
21
|
-
span_name = create_request_span_name(request_method, uri.path)
|
|
22
|
+
span_name = create_span_name(span_data, uri.path)
|
|
22
23
|
|
|
23
24
|
attributes = {
|
|
24
|
-
'http.method' =>
|
|
25
|
+
'http.method' => span_data.normalized_method,
|
|
25
26
|
'http.scheme' => uri.scheme,
|
|
26
27
|
'http.target' => uri.path,
|
|
27
28
|
'http.url' => "#{uri.scheme}://#{uri.host}",
|
|
@@ -51,15 +52,17 @@ module OpenTelemetry
|
|
|
51
52
|
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def
|
|
55
|
+
def create_span_name(span_data, request_path)
|
|
56
|
+
default_span_name = span_data.span_name
|
|
57
|
+
|
|
55
58
|
if (implementation = config[:span_name_formatter])
|
|
56
|
-
updated_span_name = implementation.call(
|
|
57
|
-
updated_span_name.is_a?(String) ? updated_span_name :
|
|
59
|
+
updated_span_name = implementation.call(span_data.normalized_method, request_path)
|
|
60
|
+
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
58
61
|
else
|
|
59
|
-
|
|
62
|
+
default_span_name
|
|
60
63
|
end
|
|
61
64
|
rescue StandardError
|
|
62
|
-
|
|
65
|
+
default_span_name
|
|
63
66
|
end
|
|
64
67
|
|
|
65
68
|
def tracer
|
|
@@ -16,18 +16,20 @@ module OpenTelemetry
|
|
|
16
16
|
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
|
17
17
|
|
|
18
18
|
def perform(req, options)
|
|
19
|
+
span_data = HttpHelper.span_attrs_for(req.verb)
|
|
20
|
+
|
|
19
21
|
uri = req.uri
|
|
20
|
-
|
|
21
|
-
span_name = create_request_span_name(request_method, uri.path)
|
|
22
|
+
span_name = create_span_name(span_data, uri.path)
|
|
22
23
|
|
|
23
24
|
attributes = {
|
|
24
|
-
'http.request.method' =>
|
|
25
|
+
'http.request.method' => span_data.normalized_method,
|
|
25
26
|
'url.scheme' => uri.scheme,
|
|
26
27
|
'url.path' => uri.path,
|
|
27
28
|
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
28
29
|
'server.address' => uri.host,
|
|
29
30
|
'server.port' => uri.port
|
|
30
31
|
}
|
|
32
|
+
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
31
33
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
32
34
|
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
33
35
|
|
|
@@ -53,15 +55,17 @@ module OpenTelemetry
|
|
|
53
55
|
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
|
54
56
|
end
|
|
55
57
|
|
|
56
|
-
def
|
|
58
|
+
def create_span_name(span_data, request_path)
|
|
59
|
+
default_span_name = span_data.span_name
|
|
60
|
+
|
|
57
61
|
if (implementation = config[:span_name_formatter])
|
|
58
|
-
updated_span_name = implementation.call(
|
|
59
|
-
updated_span_name.is_a?(String) ? updated_span_name :
|
|
62
|
+
updated_span_name = implementation.call(span_data.normalized_method, request_path)
|
|
63
|
+
updated_span_name.is_a?(String) ? updated_span_name : default_span_name
|
|
60
64
|
else
|
|
61
|
-
|
|
65
|
+
default_span_name
|
|
62
66
|
end
|
|
63
67
|
rescue StandardError
|
|
64
|
-
|
|
68
|
+
default_span_name
|
|
65
69
|
end
|
|
66
70
|
|
|
67
71
|
def tracer
|
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.27.
|
|
4
|
+
version: 0.27.1
|
|
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
|
+
date: 2025-11-25 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-http.rb
|
|
39
39
|
- lib/opentelemetry/instrumentation.rb
|
|
40
40
|
- lib/opentelemetry/instrumentation/http.rb
|
|
41
|
+
- lib/opentelemetry/instrumentation/http/http_helper.rb
|
|
41
42
|
- lib/opentelemetry/instrumentation/http/instrumentation.rb
|
|
42
43
|
- lib/opentelemetry/instrumentation/http/patches/dup/client.rb
|
|
43
44
|
- lib/opentelemetry/instrumentation/http/patches/dup/connection.rb
|
|
@@ -50,10 +51,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
|
50
51
|
licenses:
|
|
51
52
|
- Apache-2.0
|
|
52
53
|
metadata:
|
|
53
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.27.
|
|
54
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.27.1/file/CHANGELOG.md
|
|
54
55
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
|
|
55
56
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
56
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.27.
|
|
57
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.27.1
|
|
57
58
|
post_install_message:
|
|
58
59
|
rdoc_options: []
|
|
59
60
|
require_paths:
|