opentelemetry-instrumentation-http_client 0.23.0 → 0.24.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 +17 -1
- data/lib/opentelemetry/instrumentation/http_client/instrumentation.rb +42 -8
- data/lib/opentelemetry/instrumentation/http_client/patches/dup/client.rb +70 -0
- data/lib/opentelemetry/instrumentation/http_client/patches/dup/session.rb +34 -0
- data/lib/opentelemetry/instrumentation/http_client/patches/old/client.rb +60 -0
- data/lib/opentelemetry/instrumentation/http_client/patches/old/session.rb +34 -0
- data/lib/opentelemetry/instrumentation/http_client/patches/stable/client.rb +62 -0
- data/lib/opentelemetry/instrumentation/http_client/patches/stable/session.rb +34 -0
- data/lib/opentelemetry/instrumentation/http_client/version.rb +1 -1
- metadata +10 -160
- data/lib/opentelemetry/instrumentation/http_client/patches/client.rb +0 -58
- data/lib/opentelemetry/instrumentation/http_client/patches/session.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60b3ed3e8e11d1726975a033df4ba872f039d45732369de647a8429c2b43df6a
|
4
|
+
data.tar.gz: ad8704c3b61d5c5833b361217c88f1e396264ea5b2c8d5a6275da358e85e4945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86fb5beb404148d290b468b46f6d8ff6287b2fd6c4a62e7839267951b58ff264d9698f44af86726b3da763e956c264bc7cfd6f1df3d5ed1c77afa9bbb3ead963
|
7
|
+
data.tar.gz: 01aab5af766e9b0b8c988d52c8673b75cce65574b08e0dc530119eabd80198593708817802d08b3d31838f677ce4d2dff1c35d9eb1c8f42e2cdafcd0c704d951
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-http_client
|
2
2
|
|
3
|
+
### v0.24.0 / 2025-07-29
|
4
|
+
|
5
|
+
* ADDED: Add HTTPClient `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable [#1588](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/1588)
|
6
|
+
|
3
7
|
### v0.23.0 / 2025-01-16
|
4
8
|
|
5
9
|
* BREAKING CHANGE: Set minimum supported version to Ruby 3.1
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ end
|
|
32
32
|
|
33
33
|
## Examples
|
34
34
|
|
35
|
-
Example usage can be seen in the `./example/trace_demonstration.rb` file
|
35
|
+
Example usage can be seen in the [`./example/trace_demonstration.rb` file](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/http_client/example/trace_demonstration.rb)
|
36
36
|
|
37
37
|
## How can I get involved?
|
38
38
|
|
@@ -52,3 +52,19 @@ The `opentelemetry-instrumentation-http_client` gem is distributed under the Apa
|
|
52
52
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
53
53
|
[slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
|
54
54
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
|
55
|
+
|
56
|
+
## HTTP semantic convention stability
|
57
|
+
|
58
|
+
In the OpenTelemetry ecosystem, HTTP semantic conventions have now reached a stable state. However, the initial HttpClient instrumentation was introduced before this stability was achieved, which resulted in HTTP attributes being based on an older version of the semantic conventions.
|
59
|
+
|
60
|
+
To facilitate the migration to stable semantic conventions, you can use the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable. This variable allows you to opt-in to the new stable conventions, ensuring compatibility and future-proofing your instrumentation.
|
61
|
+
|
62
|
+
When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify which conventions you wish to adopt:
|
63
|
+
|
64
|
+
- `http` - Emits the stable HTTP and networking conventions and ceases emitting the old conventions previously emitted by the instrumentation.
|
65
|
+
- `http/dup` - Emits both the old and stable HTTP and networking conventions, enabling a phased rollout of the stable semantic conventions.
|
66
|
+
- Default behavior (in the absence of either value) is to continue emitting the old HTTP and networking conventions the instrumentation previously emitted.
|
67
|
+
|
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
|
+
|
70
|
+
For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
|
@@ -12,8 +12,9 @@ module OpenTelemetry
|
|
12
12
|
# The Instrumentation class contains logic to detect and install the HttpClient instrumentation
|
13
13
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
14
14
|
install do |_config|
|
15
|
-
|
16
|
-
|
15
|
+
patch_type = determine_semconv
|
16
|
+
send(:"require_dependencies_#{patch_type}")
|
17
|
+
send(:"patch_#{patch_type}")
|
17
18
|
end
|
18
19
|
|
19
20
|
present do
|
@@ -22,14 +23,47 @@ module OpenTelemetry
|
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
26
|
+
def determine_semconv
|
27
|
+
stability_opt_in = ENV.fetch('OTEL_SEMCONV_STABILITY_OPT_IN', '')
|
28
|
+
values = stability_opt_in.split(',').map(&:strip)
|
29
|
+
|
30
|
+
if values.include?('http/dup')
|
31
|
+
'dup'
|
32
|
+
elsif values.include?('http')
|
33
|
+
'stable'
|
34
|
+
else
|
35
|
+
'old'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def patch_dup
|
40
|
+
::HTTPClient.prepend(Patches::Dup::Client)
|
41
|
+
::HTTPClient::Session.prepend(Patches::Dup::Session)
|
42
|
+
end
|
43
|
+
|
44
|
+
def patch_old
|
45
|
+
::HTTPClient.prepend(Patches::Old::Client)
|
46
|
+
::HTTPClient::Session.prepend(Patches::Old::Session)
|
47
|
+
end
|
48
|
+
|
49
|
+
def patch_stable
|
50
|
+
::HTTPClient.prepend(Patches::Stable::Client)
|
51
|
+
::HTTPClient::Session.prepend(Patches::Stable::Session)
|
52
|
+
end
|
53
|
+
|
54
|
+
def require_dependencies_dup
|
55
|
+
require_relative 'patches/dup/client'
|
56
|
+
require_relative 'patches/dup/session'
|
57
|
+
end
|
58
|
+
|
59
|
+
def require_dependencies_old
|
60
|
+
require_relative 'patches/old/client'
|
61
|
+
require_relative 'patches/old/session'
|
28
62
|
end
|
29
63
|
|
30
|
-
def
|
31
|
-
require_relative 'patches/client'
|
32
|
-
require_relative 'patches/session'
|
64
|
+
def require_dependencies_stable
|
65
|
+
require_relative 'patches/stable/client'
|
66
|
+
require_relative 'patches/stable/session'
|
33
67
|
end
|
34
68
|
end
|
35
69
|
end
|
@@ -0,0 +1,70 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Dup
|
12
|
+
# Module to prepend to HTTPClient for instrumentation
|
13
|
+
module Client
|
14
|
+
# Constant for the HTTP status range
|
15
|
+
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def do_get_block(req, proxy, conn, &)
|
20
|
+
uri = req.header.request_uri
|
21
|
+
url = "#{uri.scheme}://#{uri.host}"
|
22
|
+
request_method = req.header.request_method
|
23
|
+
|
24
|
+
attributes = {
|
25
|
+
'http.method' => request_method,
|
26
|
+
'http.scheme' => uri.scheme,
|
27
|
+
'http.target' => uri.path,
|
28
|
+
'http.url' => url,
|
29
|
+
'net.peer.name' => uri.host,
|
30
|
+
'net.peer.port' => uri.port,
|
31
|
+
# stable semantic conventions
|
32
|
+
'http.request.method' => request_method,
|
33
|
+
'url.scheme' => uri.scheme,
|
34
|
+
'url.path' => uri.path,
|
35
|
+
'url.full' => url,
|
36
|
+
'server.address' => uri.host,
|
37
|
+
'server.port' => uri.port
|
38
|
+
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
39
|
+
|
40
|
+
attributes['url.query'] = uri.query unless uri.query.nil?
|
41
|
+
|
42
|
+
tracer.in_span(request_method, attributes: attributes, kind: :client) do |span|
|
43
|
+
OpenTelemetry.propagation.inject(req.header)
|
44
|
+
super.tap do
|
45
|
+
response = conn.pop
|
46
|
+
annotate_span_with_response!(span, response)
|
47
|
+
conn.push response
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def annotate_span_with_response!(span, response)
|
53
|
+
return unless response&.status_code
|
54
|
+
|
55
|
+
status_code = response.status_code.to_i
|
56
|
+
|
57
|
+
span.set_attribute('http.status_code', status_code)
|
58
|
+
span.set_attribute('http.response.status_code', status_code)
|
59
|
+
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
60
|
+
end
|
61
|
+
|
62
|
+
def tracer
|
63
|
+
HttpClient::Instrumentation.instance.tracer
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Dup
|
12
|
+
# Module to prepend to HTTPClient::Session for instrumentation
|
13
|
+
module Session
|
14
|
+
def connect
|
15
|
+
site = @proxy || @dest
|
16
|
+
url = site.addr
|
17
|
+
|
18
|
+
attributes = { 'http.url' => url, 'url.full' => url }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
19
|
+
tracer.in_span('CONNECT', attributes: attributes) do
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tracer
|
27
|
+
HttpClient::Instrumentation.instance.tracer
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Old
|
12
|
+
# Module to prepend to HTTPClient for instrumentation
|
13
|
+
module Client
|
14
|
+
# Constant for the HTTP status range
|
15
|
+
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def do_get_block(req, proxy, conn, &)
|
20
|
+
uri = req.header.request_uri
|
21
|
+
url = "#{uri.scheme}://#{uri.host}"
|
22
|
+
request_method = req.header.request_method
|
23
|
+
|
24
|
+
attributes = {
|
25
|
+
'http.method' => request_method,
|
26
|
+
'http.scheme' => uri.scheme,
|
27
|
+
'http.target' => uri.path,
|
28
|
+
'http.url' => url,
|
29
|
+
'net.peer.name' => uri.host,
|
30
|
+
'net.peer.port' => uri.port
|
31
|
+
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
32
|
+
|
33
|
+
tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span|
|
34
|
+
OpenTelemetry.propagation.inject(req.header)
|
35
|
+
super.tap do
|
36
|
+
response = conn.pop
|
37
|
+
annotate_span_with_response!(span, response)
|
38
|
+
conn.push response
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def annotate_span_with_response!(span, response)
|
44
|
+
return unless response&.status_code
|
45
|
+
|
46
|
+
status_code = response.status_code.to_i
|
47
|
+
|
48
|
+
span.set_attribute('http.status_code', status_code)
|
49
|
+
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
50
|
+
end
|
51
|
+
|
52
|
+
def tracer
|
53
|
+
HttpClient::Instrumentation.instance.tracer
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Old
|
12
|
+
# Module to prepend to HTTPClient::Session for instrumentation
|
13
|
+
module Session
|
14
|
+
def connect
|
15
|
+
site = @proxy || @dest
|
16
|
+
url = site.addr
|
17
|
+
|
18
|
+
attributes = { 'http.url' => url }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
19
|
+
tracer.in_span('HTTP CONNECT', attributes: attributes) do
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tracer
|
27
|
+
HttpClient::Instrumentation.instance.tracer
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Stable
|
12
|
+
# Module to prepend to HTTPClient for instrumentation
|
13
|
+
module Client
|
14
|
+
# Constant for the HTTP status range
|
15
|
+
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def do_get_block(req, proxy, conn, &)
|
20
|
+
uri = req.header.request_uri
|
21
|
+
url = "#{uri.scheme}://#{uri.host}"
|
22
|
+
request_method = req.header.request_method
|
23
|
+
|
24
|
+
attributes = {
|
25
|
+
'http.request.method' => request_method,
|
26
|
+
'url.scheme' => uri.scheme,
|
27
|
+
'url.path' => uri.path,
|
28
|
+
'url.full' => url,
|
29
|
+
'server.address' => uri.host,
|
30
|
+
'server.port' => uri.port
|
31
|
+
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
32
|
+
|
33
|
+
attributes['url.query'] = uri.query unless uri.query.nil?
|
34
|
+
|
35
|
+
tracer.in_span(request_method, attributes: attributes, kind: :client) do |span|
|
36
|
+
OpenTelemetry.propagation.inject(req.header)
|
37
|
+
super.tap do
|
38
|
+
response = conn.pop
|
39
|
+
annotate_span_with_response!(span, response)
|
40
|
+
conn.push response
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def annotate_span_with_response!(span, response)
|
46
|
+
return unless response&.status_code
|
47
|
+
|
48
|
+
status_code = response.status_code.to_i
|
49
|
+
|
50
|
+
span.set_attribute('http.response.status_code', status_code)
|
51
|
+
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
52
|
+
end
|
53
|
+
|
54
|
+
def tracer
|
55
|
+
HttpClient::Instrumentation.instance.tracer
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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 HttpClient
|
10
|
+
module Patches
|
11
|
+
module Stable
|
12
|
+
# Module to prepend to HTTPClient::Session for instrumentation
|
13
|
+
module Session
|
14
|
+
def connect
|
15
|
+
site = @proxy || @dest
|
16
|
+
url = site.addr
|
17
|
+
|
18
|
+
attributes = { 'url.full' => url }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
19
|
+
tracer.in_span('CONNECT', attributes: attributes) do
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tracer
|
27
|
+
HttpClient::Instrumentation.instance.tracer
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
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.24.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: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -38,160 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.23.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: appraisal
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.5'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.4'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '5.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: opentelemetry-sdk
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.1'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.1'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: opentelemetry-test-helpers
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.3'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.3'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '13.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '13.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.69.1
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.69.1
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rubocop-performance
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 1.23.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 1.23.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 0.17.1
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 0.17.1
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: webmock
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 3.24.0
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 3.24.0
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: yard
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0.9'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0.9'
|
195
41
|
description: HttpClient instrumentation for the OpenTelemetry framework
|
196
42
|
email:
|
197
43
|
- cncf-opentelemetry-contributors@lists.cncf.io
|
@@ -207,17 +53,21 @@ files:
|
|
207
53
|
- lib/opentelemetry/instrumentation.rb
|
208
54
|
- lib/opentelemetry/instrumentation/http_client.rb
|
209
55
|
- lib/opentelemetry/instrumentation/http_client/instrumentation.rb
|
210
|
-
- lib/opentelemetry/instrumentation/http_client/patches/client.rb
|
211
|
-
- lib/opentelemetry/instrumentation/http_client/patches/session.rb
|
56
|
+
- lib/opentelemetry/instrumentation/http_client/patches/dup/client.rb
|
57
|
+
- lib/opentelemetry/instrumentation/http_client/patches/dup/session.rb
|
58
|
+
- lib/opentelemetry/instrumentation/http_client/patches/old/client.rb
|
59
|
+
- lib/opentelemetry/instrumentation/http_client/patches/old/session.rb
|
60
|
+
- lib/opentelemetry/instrumentation/http_client/patches/stable/client.rb
|
61
|
+
- lib/opentelemetry/instrumentation/http_client/patches/stable/session.rb
|
212
62
|
- lib/opentelemetry/instrumentation/http_client/version.rb
|
213
63
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
214
64
|
licenses:
|
215
65
|
- Apache-2.0
|
216
66
|
metadata:
|
217
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.
|
67
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.24.0/file/CHANGELOG.md
|
218
68
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http_client
|
219
69
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
220
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.
|
70
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http_client/0.24.0
|
221
71
|
post_install_message:
|
222
72
|
rdoc_options: []
|
223
73
|
require_paths:
|
@@ -1,58 +0,0 @@
|
|
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 HttpClient
|
10
|
-
module Patches
|
11
|
-
# Module to prepend to HTTPClient for instrumentation
|
12
|
-
module Client
|
13
|
-
# Constant for the HTTP status range
|
14
|
-
HTTP_STATUS_SUCCESS_RANGE = (100..399)
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def do_get_block(req, proxy, conn, &block)
|
19
|
-
uri = req.header.request_uri
|
20
|
-
url = "#{uri.scheme}://#{uri.host}"
|
21
|
-
request_method = req.header.request_method
|
22
|
-
|
23
|
-
attributes = {
|
24
|
-
'http.method' => request_method,
|
25
|
-
'http.scheme' => uri.scheme,
|
26
|
-
'http.target' => uri.path,
|
27
|
-
'http.url' => url,
|
28
|
-
'net.peer.name' => uri.host,
|
29
|
-
'net.peer.port' => uri.port
|
30
|
-
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
31
|
-
|
32
|
-
tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span|
|
33
|
-
OpenTelemetry.propagation.inject(req.header)
|
34
|
-
super.tap do
|
35
|
-
response = conn.pop
|
36
|
-
annotate_span_with_response!(span, response)
|
37
|
-
conn.push response
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def annotate_span_with_response!(span, response)
|
43
|
-
return unless response&.status_code
|
44
|
-
|
45
|
-
status_code = response.status_code.to_i
|
46
|
-
|
47
|
-
span.set_attribute('http.status_code', status_code)
|
48
|
-
span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
|
49
|
-
end
|
50
|
-
|
51
|
-
def tracer
|
52
|
-
HttpClient::Instrumentation.instance.tracer
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,32 +0,0 @@
|
|
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 HttpClient
|
10
|
-
module Patches
|
11
|
-
# Module to prepend to HTTPClient::Session for instrumentation
|
12
|
-
module Session
|
13
|
-
def connect
|
14
|
-
site = @proxy || @dest
|
15
|
-
url = site.addr
|
16
|
-
|
17
|
-
attributes = { 'http.url' => url }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
18
|
-
tracer.in_span('HTTP CONNECT', attributes: attributes) do
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def tracer
|
26
|
-
HttpClient::Instrumentation.instance.tracer
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|