opentelemetry-instrumentation-http 0.23.5 → 0.25.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b044de6092ac591144450d0632775c5f605c27a9b7e0b58fa966008360ad7c6a
4
- data.tar.gz: 9a205ee24ea24d39e06dd880cb76213ba96a03f70ff45b0507fbcf1364f2f23b
3
+ metadata.gz: 347351f1f4d196a9c70e354da867ed6299514e38d643002ff91a9dce44bb3133
4
+ data.tar.gz: 2113ca4e530e625af85981c968568264a8a13e30e8e26cb35661fdb598b750a7
5
5
  SHA512:
6
- metadata.gz: 1c92c1feb8f46bdc9916de049d3e8a2e6bece014a64050a317dd7e4f7624947f4e70240c3e2375fb5dd9c6b6a1fa0dbf14297e7569afb5b54660acd0df850877
7
- data.tar.gz: 986e64b3308b194912a2d9e4c6f75c430d6bafa871312980452869f30f3b7b5002878026a9411db29f1415db65a91d58705479fee303789040977c6b3054cb32
6
+ metadata.gz: 71860640b78fed3be784626daebacb24d280916e4272f2ecb852e8036d77d14df96a22c2e57ba1958759039ec4ac55f3e75d7000c9474352b27be488273a5f19
7
+ data.tar.gz: 64cac80aadb5e34fe9e42d9e08f9c4b53642a3d78ed0a0dd7fd15aad344ca6b98257913b3c8a1d1cd1f6afc5d2dcc9d61e0e9d5065e7dbbeaaac584eabe53b86
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-instrumentation-http
2
2
 
3
+ ### v0.25.0 / 2025-06-17
4
+
5
+ * ADDED: Add `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable [#1547](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/1547)
6
+
7
+ ### v0.24.0 / 2025-01-16
8
+
9
+ * BREAKING CHANGE: Set minimum supported version to Ruby 3.1
10
+
11
+ * ADDED: Set minimum supported version to Ruby 3.1
12
+
3
13
  ### v0.23.5 / 2024-11-26
4
14
 
5
15
  * CHANGED: Performance Freeze all range objects #1222
@@ -18,28 +28,28 @@
18
28
 
19
29
  ### v0.23.1 / 2023-06-05
20
30
 
21
- * FIXED: Base config options
31
+ * FIXED: Base config options
22
32
 
23
33
  ### v0.23.0 / 2023-05-15
24
34
 
25
- * ADDED: Add span_preprocessor hook
35
+ * ADDED: Add span_preprocessor hook
26
36
 
27
37
  ### v0.22.0 / 2023-04-17
28
38
 
29
- * BREAKING CHANGE: Drop support for EoL Ruby 2.7
39
+ * BREAKING CHANGE: Drop support for EoL Ruby 2.7
30
40
 
31
- * ADDED: Drop support for EoL Ruby 2.7
41
+ * ADDED: Drop support for EoL Ruby 2.7
32
42
 
33
43
  ### v0.21.0 / 2023-01-14
34
44
 
35
- * ADDED: Add request/response hooks to more http clients
36
- * DOCS: Fix gem homepage
37
- * DOCS: More gem documentation fixes
45
+ * ADDED: Add request/response hooks to more http clients
46
+ * DOCS: Fix gem homepage
47
+ * DOCS: More gem documentation fixes
38
48
 
39
49
  ### v0.20.0 / 2022-06-09
40
50
 
41
51
  * Upgrading Base dependency version
42
- * FIXED: Broken test file requirements
52
+ * FIXED: Broken test file requirements
43
53
 
44
54
  ### v0.19.6 / 2022-05-05
45
55
 
@@ -47,15 +57,15 @@
47
57
 
48
58
  ### v0.19.5 / 2022-05-02
49
59
 
50
- * FIXED: RubyGems Fallback
60
+ * FIXED: RubyGems Fallback
51
61
 
52
62
  ### v0.19.4 / 2022-02-02
53
63
 
54
- * FIXED: Excessive hash creation on context attr merging
64
+ * FIXED: Excessive hash creation on context attr merging
55
65
 
56
66
  ### v0.19.3 / 2021-12-01
57
67
 
58
- * FIXED: Change net attribute names to match the semantic conventions spec for http
68
+ * FIXED: Change net attribute names to match the semantic conventions spec for http
59
69
 
60
70
  ### v0.19.2 / 2021-09-29
61
71
 
@@ -67,9 +77,9 @@
67
77
 
68
78
  ### v0.19.0 / 2021-06-23
69
79
 
70
- * BREAKING CHANGE: Total order constraint on span.status=
80
+ * BREAKING CHANGE: Total order constraint on span.status=
71
81
 
72
- * FIXED: Total order constraint on span.status=
82
+ * FIXED: Total order constraint on span.status=
73
83
 
74
84
  ### v0.18.0 / 2021-05-21
75
85
 
data/README.md CHANGED
@@ -44,7 +44,7 @@ end
44
44
 
45
45
  ## Examples
46
46
 
47
- Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/http/example/trace_demonstration.rb)
47
+ Example usage can be seen in the [`./example/trace_demonstration.rb` file](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/http/example/trace_demonstration.rb)
48
48
 
49
49
  ## How can I get involved?
50
50
 
@@ -64,3 +64,19 @@ The `opentelemetry-instrumentation-http` gem is distributed under the Apache 2.0
64
64
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
65
65
  [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
66
66
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
67
+
68
+ ## HTTP semantic convention stability
69
+
70
+ In the OpenTelemetry ecosystem, HTTP semantic conventions have now reached a stable state. However, the initial HTTP instrumentation was introduced before this stability was achieved, which resulted in HTTP attributes being based on an older version of the semantic conventions.
71
+
72
+ 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.
73
+
74
+ When setting the value for `OTEL_SEMCONV_STABILITY_OPT_IN`, you can specify which conventions you wish to adopt:
75
+
76
+ - `http` - Emits the stable HTTP and networking conventions and ceases emitting the old conventions previously emitted by the instrumentation.
77
+ - `http/dup` - Emits both the old and stable HTTP and networking conventions, enabling a phased rollout of the stable semantic conventions.
78
+ - Default behavior (in the absence of either value) is to continue emitting the old HTTP and networking conventions the instrumentation previously emitted.
79
+
80
+ During the transition from old to stable conventions, 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 HTTP instrumentation should consider all three patches.
81
+
82
+ For additional information on migration, please refer to our [documentation](https://opentelemetry.io/docs/specs/semconv/non-normative/http-migration/).
@@ -10,8 +10,9 @@ module OpenTelemetry
10
10
  # The Instrumentation class contains logic to detect and install the Http instrumentation
11
11
  class Instrumentation < OpenTelemetry::Instrumentation::Base
12
12
  install do |_config|
13
- require_dependencies
14
- patch
13
+ patch_type = determine_semconv
14
+ send(:"require_dependencies_#{patch_type}")
15
+ send(:"patch_#{patch_type}")
15
16
  end
16
17
 
17
18
  present do
@@ -20,14 +21,47 @@ module OpenTelemetry
20
21
 
21
22
  option :span_name_formatter, default: nil, validate: :callable
22
23
 
23
- def patch
24
- ::HTTP::Client.prepend(Patches::Client)
25
- ::HTTP::Connection.prepend(Patches::Connection)
24
+ def determine_semconv
25
+ stability_opt_in = ENV.fetch('OTEL_SEMCONV_STABILITY_OPT_IN', '')
26
+ values = stability_opt_in.split(',').map(&:strip)
27
+
28
+ if values.include?('http/dup')
29
+ 'dup'
30
+ elsif values.include?('http')
31
+ 'stable'
32
+ else
33
+ 'old'
34
+ end
35
+ end
36
+
37
+ def patch_old
38
+ ::HTTP::Client.prepend(Patches::Old::Client)
39
+ ::HTTP::Connection.prepend(Patches::Old::Connection)
40
+ end
41
+
42
+ def patch_dup
43
+ ::HTTP::Client.prepend(Patches::Dup::Client)
44
+ ::HTTP::Connection.prepend(Patches::Dup::Connection)
45
+ end
46
+
47
+ def patch_stable
48
+ ::HTTP::Client.prepend(Patches::Stable::Client)
49
+ ::HTTP::Connection.prepend(Patches::Stable::Connection)
50
+ end
51
+
52
+ def require_dependencies_dup
53
+ require_relative 'patches/dup/client'
54
+ require_relative 'patches/dup/connection'
55
+ end
56
+
57
+ def require_dependencies_old
58
+ require_relative 'patches/old/client'
59
+ require_relative 'patches/old/connection'
26
60
  end
27
61
 
28
- def require_dependencies
29
- require_relative 'patches/client'
30
- require_relative 'patches/connection'
62
+ def require_dependencies_stable
63
+ require_relative 'patches/stable/client'
64
+ require_relative 'patches/stable/connection'
31
65
  end
32
66
  end
33
67
  end
@@ -0,0 +1,84 @@
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 Patches
11
+ # Module using old and stable HTTP semantic conventions
12
+ module Dup
13
+ # Module to prepend to HTTP::Client for instrumentation
14
+ module Client
15
+ # Constant for the HTTP status range
16
+ HTTP_STATUS_SUCCESS_RANGE = (100..399)
17
+
18
+ def perform(req, options)
19
+ uri = req.uri
20
+ request_method = req.verb.to_s.upcase
21
+ span_name = create_request_span_name(request_method, uri.path)
22
+
23
+ attributes = {
24
+ # old semconv
25
+ 'http.method' => request_method,
26
+ 'http.scheme' => uri.scheme,
27
+ 'http.target' => uri.path,
28
+ 'http.url' => "#{uri.scheme}://#{uri.host}",
29
+ 'net.peer.name' => uri.host,
30
+ 'net.peer.port' => uri.port,
31
+ # stable semconv
32
+ 'http.request.method' => request_method,
33
+ 'url.scheme' => uri.scheme,
34
+ 'url.path' => uri.path,
35
+ 'url.full' => "#{uri.scheme}://#{uri.host}",
36
+ 'server.address' => uri.host,
37
+ 'server.port' => uri.port
38
+ }
39
+ attributes['url.query'] = uri.query unless uri.query.nil?
40
+ attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
41
+
42
+ tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
43
+ OpenTelemetry.propagation.inject(req.headers)
44
+ super.tap do |response|
45
+ annotate_span_with_response!(span, response)
46
+ end
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def config
53
+ OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
54
+ end
55
+
56
+ def annotate_span_with_response!(span, response)
57
+ return unless response&.status
58
+
59
+ status_code = response.status.to_i
60
+ span.set_attribute('http.status_code', status_code) # old semconv
61
+ span.set_attribute('http.response.status_code', status_code) # stable semconv
62
+ span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
63
+ end
64
+
65
+ def create_request_span_name(request_method, request_path)
66
+ if (implementation = config[:span_name_formatter])
67
+ updated_span_name = implementation.call(request_method, request_path)
68
+ updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
69
+ else
70
+ "HTTP #{request_method}"
71
+ end
72
+ rescue StandardError
73
+ "HTTP #{request_method}"
74
+ end
75
+
76
+ def tracer
77
+ HTTP::Instrumentation.instance.tracer
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,40 @@
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 Patches
11
+ # Module using old and stable HTTP semantic conventions
12
+ module Dup
13
+ # Module to prepend to HTTP::Connection for instrumentation
14
+ module Connection
15
+ def initialize(req, options)
16
+ attributes = {
17
+ # old semconv
18
+ 'net.peer.name' => req.uri.host,
19
+ 'net.peer.port' => req.uri.port,
20
+ # stable semconv
21
+ 'server.address' => req.uri.host,
22
+ 'server.port' => req.uri.port
23
+ }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
24
+
25
+ tracer.in_span('HTTP CONNECT', attributes: attributes) do
26
+ super
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def tracer
33
+ HTTP::Instrumentation.instance.tracer
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,73 @@
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 Patches
11
+ # Module using old HTTP semantic conventions
12
+ module Old
13
+ # Module to prepend to HTTP::Client for instrumentation
14
+ module Client
15
+ # Constant for the HTTP status range
16
+ HTTP_STATUS_SUCCESS_RANGE = (100..399)
17
+
18
+ def perform(req, options)
19
+ uri = req.uri
20
+ request_method = req.verb.to_s.upcase
21
+ span_name = create_request_span_name(request_method, uri.path)
22
+
23
+ attributes = {
24
+ 'http.method' => request_method,
25
+ 'http.scheme' => uri.scheme,
26
+ 'http.target' => uri.path,
27
+ 'http.url' => "#{uri.scheme}://#{uri.host}",
28
+ 'net.peer.name' => uri.host,
29
+ 'net.peer.port' => uri.port
30
+ }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
31
+
32
+ tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
33
+ OpenTelemetry.propagation.inject(req.headers)
34
+ super.tap do |response|
35
+ annotate_span_with_response!(span, response)
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def config
43
+ OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
44
+ end
45
+
46
+ def annotate_span_with_response!(span, response)
47
+ return unless response&.status
48
+
49
+ status_code = response.status.to_i
50
+ span.set_attribute('http.status_code', status_code)
51
+ span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
52
+ end
53
+
54
+ def create_request_span_name(request_method, request_path)
55
+ if (implementation = config[:span_name_formatter])
56
+ updated_span_name = implementation.call(request_method, request_path)
57
+ updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
58
+ else
59
+ "HTTP #{request_method}"
60
+ end
61
+ rescue StandardError
62
+ "HTTP #{request_method}"
63
+ end
64
+
65
+ def tracer
66
+ HTTP::Instrumentation.instance.tracer
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,36 @@
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 Patches
11
+ # Module using old HTTP semantic conventions
12
+ module Old
13
+ # Module to prepend to HTTP::Connection for instrumentation
14
+ module Connection
15
+ def initialize(req, options)
16
+ attributes = {
17
+ 'net.peer.name' => req.uri.host,
18
+ 'net.peer.port' => req.uri.port
19
+ }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
20
+
21
+ tracer.in_span('HTTP CONNECT', attributes: attributes) do
22
+ super
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def tracer
29
+ HTTP::Instrumentation.instance.tracer
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,75 @@
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 Patches
11
+ # Module using stable HTTP semantic conventions
12
+ module Stable
13
+ # Module to prepend to HTTP::Client for instrumentation
14
+ module Client
15
+ # Constant for the HTTP status range
16
+ HTTP_STATUS_SUCCESS_RANGE = (100..399)
17
+
18
+ def perform(req, options)
19
+ uri = req.uri
20
+ request_method = req.verb.to_s.upcase
21
+ span_name = create_request_span_name(request_method, uri.path)
22
+
23
+ attributes = {
24
+ 'http.request.method' => request_method,
25
+ 'url.scheme' => uri.scheme,
26
+ 'url.path' => uri.path,
27
+ 'url.full' => "#{uri.scheme}://#{uri.host}",
28
+ 'server.address' => uri.host,
29
+ 'server.port' => uri.port
30
+ }
31
+ attributes['url.query'] = uri.query unless uri.query.nil?
32
+ attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
33
+
34
+ tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
35
+ OpenTelemetry.propagation.inject(req.headers)
36
+ super.tap do |response|
37
+ annotate_span_with_response!(span, response)
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def config
45
+ OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
46
+ end
47
+
48
+ def annotate_span_with_response!(span, response)
49
+ return unless response&.status
50
+
51
+ status_code = response.status.to_i
52
+ span.set_attribute('http.response.status_code', status_code)
53
+ span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code)
54
+ end
55
+
56
+ def create_request_span_name(request_method, request_path)
57
+ if (implementation = config[:span_name_formatter])
58
+ updated_span_name = implementation.call(request_method, request_path)
59
+ updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
60
+ else
61
+ "HTTP #{request_method}"
62
+ end
63
+ rescue StandardError
64
+ "HTTP #{request_method}"
65
+ end
66
+
67
+ def tracer
68
+ HTTP::Instrumentation.instance.tracer
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,36 @@
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 Patches
11
+ # Module using stable HTTP semantic conventions
12
+ module Stable
13
+ # Module to prepend to HTTP::Connection for instrumentation
14
+ module Connection
15
+ def initialize(req, options)
16
+ attributes = {
17
+ 'server.address' => req.uri.host,
18
+ 'server.port' => req.uri.port
19
+ }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
20
+
21
+ tracer.in_span('HTTP CONNECT', attributes: attributes) do
22
+ super
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def tracer
29
+ HTTP::Instrumentation.instance.tracer
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module HTTP
10
- VERSION = '0.23.5'
10
+ VERSION = '0.25.0'
11
11
  end
12
12
  end
13
13
  end
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.23.5
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-27 00:00:00.000000000 Z
11
+ date: 2025-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -30,182 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.22.1
33
+ version: 0.23.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.22.1
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: rspec-mocks
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.68.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.68.0
153
- - !ruby/object:Gem::Dependency
154
- name: rubocop-performance
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 1.23.0
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 1.23.0
167
- - !ruby/object:Gem::Dependency
168
- name: simplecov
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 0.17.1
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: 0.17.1
181
- - !ruby/object:Gem::Dependency
182
- name: webmock
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: 3.24.0
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: 3.24.0
195
- - !ruby/object:Gem::Dependency
196
- name: yard
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '0.9'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '0.9'
40
+ version: 0.23.0
209
41
  description: HTTP instrumentation for the OpenTelemetry framework
210
42
  email:
211
43
  - cncf-opentelemetry-contributors@lists.cncf.io
@@ -221,18 +53,22 @@ files:
221
53
  - lib/opentelemetry/instrumentation.rb
222
54
  - lib/opentelemetry/instrumentation/http.rb
223
55
  - lib/opentelemetry/instrumentation/http/instrumentation.rb
224
- - lib/opentelemetry/instrumentation/http/patches/client.rb
225
- - lib/opentelemetry/instrumentation/http/patches/connection.rb
56
+ - lib/opentelemetry/instrumentation/http/patches/dup/client.rb
57
+ - lib/opentelemetry/instrumentation/http/patches/dup/connection.rb
58
+ - lib/opentelemetry/instrumentation/http/patches/old/client.rb
59
+ - lib/opentelemetry/instrumentation/http/patches/old/connection.rb
60
+ - lib/opentelemetry/instrumentation/http/patches/stable/client.rb
61
+ - lib/opentelemetry/instrumentation/http/patches/stable/connection.rb
226
62
  - lib/opentelemetry/instrumentation/http/version.rb
227
63
  homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
228
64
  licenses:
229
65
  - Apache-2.0
230
66
  metadata:
231
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.5/file/CHANGELOG.md
67
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.25.0/file/CHANGELOG.md
232
68
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
233
69
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
234
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.5
235
- post_install_message:
70
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.25.0
71
+ post_install_message:
236
72
  rdoc_options: []
237
73
  require_paths:
238
74
  - lib
@@ -240,15 +76,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
76
  requirements:
241
77
  - - ">="
242
78
  - !ruby/object:Gem::Version
243
- version: '3.0'
79
+ version: '3.1'
244
80
  required_rubygems_version: !ruby/object:Gem::Requirement
245
81
  requirements:
246
82
  - - ">="
247
83
  - !ruby/object:Gem::Version
248
84
  version: '0'
249
85
  requirements: []
250
- rubygems_version: 3.2.33
251
- signing_key:
86
+ rubygems_version: 3.3.27
87
+ signing_key:
252
88
  specification_version: 4
253
89
  summary: HTTP instrumentation for the OpenTelemetry framework
254
90
  test_files: []
@@ -1,70 +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 HTTP
10
- module Patches
11
- # Module to prepend to HTTP::Client for instrumentation
12
- module Client
13
- # Constant for the HTTP status range
14
- HTTP_STATUS_SUCCESS_RANGE = (100..399)
15
-
16
- def perform(req, options)
17
- uri = req.uri
18
- request_method = req.verb.to_s.upcase
19
- span_name = create_request_span_name(request_method, uri.path)
20
-
21
- attributes = {
22
- 'http.method' => request_method,
23
- 'http.scheme' => uri.scheme,
24
- 'http.target' => uri.path,
25
- 'http.url' => "#{uri.scheme}://#{uri.host}",
26
- 'net.peer.name' => uri.host,
27
- 'net.peer.port' => uri.port
28
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
29
-
30
- tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
31
- OpenTelemetry.propagation.inject(req.headers)
32
- super.tap do |response|
33
- annotate_span_with_response!(span, response)
34
- end
35
- end
36
- end
37
-
38
- private
39
-
40
- def config
41
- OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
42
- end
43
-
44
- def annotate_span_with_response!(span, response)
45
- return unless response&.status
46
-
47
- status_code = response.status.to_i
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 create_request_span_name(request_method, request_path)
53
- if (implementation = config[:span_name_formatter])
54
- updated_span_name = implementation.call(request_method, request_path)
55
- updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
56
- else
57
- "HTTP #{request_method}"
58
- end
59
- rescue StandardError
60
- "HTTP #{request_method}"
61
- end
62
-
63
- def tracer
64
- HTTP::Instrumentation.instance.tracer
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,33 +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 HTTP
10
- module Patches
11
- # Module to prepend to HTTP::Connection for instrumentation
12
- module Connection
13
- def initialize(req, options)
14
- attributes = {
15
- 'net.peer.name' => req.uri.host,
16
- 'net.peer.port' => req.uri.port
17
- }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
18
-
19
- tracer.in_span('HTTP CONNECT', attributes: attributes) do
20
- super
21
- end
22
- end
23
-
24
- private
25
-
26
- def tracer
27
- HTTP::Instrumentation.instance.tracer
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end