opentelemetry-instrumentation-httpx 0.5.0 → 0.5.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/httpx/dup/plugin.rb +6 -3
- data/lib/opentelemetry/instrumentation/httpx/http_helper.rb +86 -0
- data/lib/opentelemetry/instrumentation/httpx/old/plugin.rb +4 -2
- data/lib/opentelemetry/instrumentation/httpx/stable/plugin.rb +5 -2
- data/lib/opentelemetry/instrumentation/httpx/version.rb +1 -1
- data/lib/opentelemetry/instrumentation/httpx.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: 30dd73d1b0e1e1a0ad8c6d11c942a62e97402dd249b26217782761c14ae19002
|
|
4
|
+
data.tar.gz: d9d6c07a9518e9558af0801a26ae999bfcf785854bfa0c5c6f7ae75a91124b15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7568738e6532da2c0b7f1f765d5e3e7174a78b69d352a046ff22bcab8a833bded5e0c3b5fca1e12afce3badad44e2e3666398f9dd716f485a7126737e19b2519
|
|
7
|
+
data.tar.gz: eff4bb80b79ecc1e1b54e7dc22a4785435754fe08356ab0cccccbb145062bca309e4dd0813f6796697c420ef97f256b7b22e37bf6f4a6b7ccb9e9fd9f08fdff7
|
data/CHANGELOG.md
CHANGED
|
@@ -72,17 +72,19 @@ module OpenTelemetry
|
|
|
72
72
|
verb = request.verb
|
|
73
73
|
uri = request.uri
|
|
74
74
|
|
|
75
|
+
span_data = HttpHelper.span_attrs_for(verb)
|
|
76
|
+
|
|
75
77
|
config = HTTPX::Instrumentation.instance.config
|
|
76
78
|
|
|
77
79
|
attributes = {
|
|
78
80
|
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => uri.host,
|
|
79
|
-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD =>
|
|
81
|
+
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
|
|
80
82
|
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => uri.scheme,
|
|
81
83
|
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => uri.path,
|
|
82
84
|
OpenTelemetry::SemanticConventions::Trace::HTTP_URL => "#{uri.scheme}://#{uri.host}",
|
|
83
85
|
OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => uri.host,
|
|
84
86
|
OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => uri.port,
|
|
85
|
-
'http.request.method' =>
|
|
87
|
+
'http.request.method' => span_data.normalized_method,
|
|
86
88
|
'url.scheme' => uri.scheme,
|
|
87
89
|
'url.path' => uri.path,
|
|
88
90
|
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
@@ -90,11 +92,12 @@ module OpenTelemetry
|
|
|
90
92
|
'server.port' => uri.port
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
93
96
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
94
97
|
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
|
|
95
98
|
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
96
99
|
|
|
97
|
-
span = tracer.start_span(
|
|
100
|
+
span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client, start_timestamp: start_time)
|
|
98
101
|
|
|
99
102
|
OpenTelemetry::Trace.with_span(span) do
|
|
100
103
|
OpenTelemetry.propagation.inject(request.headers)
|
|
@@ -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 HTTPX
|
|
10
|
+
# Utility module for normalizing HTTP methods according to OpenTelemetry semantic conventions
|
|
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
|
|
@@ -71,11 +71,13 @@ module OpenTelemetry
|
|
|
71
71
|
verb = request.verb
|
|
72
72
|
uri = request.uri
|
|
73
73
|
|
|
74
|
+
span_data = HttpHelper.span_attrs_for(verb, semconv: :old)
|
|
75
|
+
|
|
74
76
|
config = HTTPX::Instrumentation.instance.config
|
|
75
77
|
|
|
76
78
|
attributes = {
|
|
77
79
|
OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => uri.host,
|
|
78
|
-
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD =>
|
|
80
|
+
OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => span_data.normalized_method,
|
|
79
81
|
OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => uri.scheme,
|
|
80
82
|
OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => uri.path,
|
|
81
83
|
OpenTelemetry::SemanticConventions::Trace::HTTP_URL => "#{uri.scheme}://#{uri.host}",
|
|
@@ -86,7 +88,7 @@ module OpenTelemetry
|
|
|
86
88
|
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
|
|
87
89
|
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
88
90
|
|
|
89
|
-
span = tracer.start_span(
|
|
91
|
+
span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client, start_timestamp: start_time)
|
|
90
92
|
|
|
91
93
|
OpenTelemetry::Trace.with_span(span) do
|
|
92
94
|
OpenTelemetry.propagation.inject(request.headers)
|
|
@@ -71,21 +71,24 @@ module OpenTelemetry
|
|
|
71
71
|
verb = request.verb
|
|
72
72
|
uri = request.uri
|
|
73
73
|
|
|
74
|
+
span_data = HttpHelper.span_attrs_for(verb)
|
|
75
|
+
|
|
74
76
|
config = HTTPX::Instrumentation.instance.config
|
|
75
77
|
|
|
76
78
|
attributes = {
|
|
77
|
-
'http.request.method' =>
|
|
79
|
+
'http.request.method' => span_data.normalized_method,
|
|
78
80
|
'url.scheme' => uri.scheme,
|
|
79
81
|
'url.path' => uri.path,
|
|
80
82
|
'url.full' => "#{uri.scheme}://#{uri.host}",
|
|
81
83
|
'server.address' => uri.host,
|
|
82
84
|
'server.port' => uri.port
|
|
83
85
|
}
|
|
86
|
+
attributes['http.request.method_original'] = span_data.original_method if span_data.original_method
|
|
84
87
|
attributes['url.query'] = uri.query unless uri.query.nil?
|
|
85
88
|
attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] if config[:peer_service]
|
|
86
89
|
attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
|
87
90
|
|
|
88
|
-
span = tracer.start_span(
|
|
91
|
+
span = tracer.start_span(span_data.span_name, attributes: attributes, kind: :client, start_timestamp: start_time)
|
|
89
92
|
|
|
90
93
|
OpenTelemetry::Trace.with_span(span) do
|
|
91
94
|
OpenTelemetry.propagation.inject(request.headers)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opentelemetry-instrumentation-httpx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.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
|
|
@@ -39,6 +39,7 @@ files:
|
|
|
39
39
|
- lib/opentelemetry/instrumentation.rb
|
|
40
40
|
- lib/opentelemetry/instrumentation/httpx.rb
|
|
41
41
|
- lib/opentelemetry/instrumentation/httpx/dup/plugin.rb
|
|
42
|
+
- lib/opentelemetry/instrumentation/httpx/http_helper.rb
|
|
42
43
|
- lib/opentelemetry/instrumentation/httpx/instrumentation.rb
|
|
43
44
|
- lib/opentelemetry/instrumentation/httpx/old/plugin.rb
|
|
44
45
|
- lib/opentelemetry/instrumentation/httpx/stable/plugin.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-httpx/0.5.
|
|
51
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-httpx/0.5.1/file/CHANGELOG.md
|
|
51
52
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
|
|
52
53
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
|
53
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-httpx/0.5.
|
|
54
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-httpx/0.5.1
|
|
54
55
|
post_install_message:
|
|
55
56
|
rdoc_options: []
|
|
56
57
|
require_paths:
|