opentelemetry-instrumentation-http 0.21.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7520e68ea064b0f26bd7b375c3570cc3bce18d049afc55fa3ceb01595bda8393
|
4
|
+
data.tar.gz: 7d7a46cdbeb076c0aace30742d8800754c2badfb379b36602f83a6d3a262b145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b98fc0bb58a37e67d04bc8d8984c4a39ec1fb71f3df5d8a74d572bf5fa41ccffafdbd291b2362a1273c7358a5fa1cfa5da29cfb8c074a19d39b48b5a13f565
|
7
|
+
data.tar.gz: 4b8f049396a292cb47cdd276a7d1dfae09ea90c6031029d4aebbadcc0d697662b25fa7045af9994f2babd3d8b32c52602a2a284520ccc0979f74a47a4454e93b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-http
|
2
2
|
|
3
|
+
### v0.23.0 / 2023-05-15
|
4
|
+
|
5
|
+
* ADDED: Add span_preprocessor hook
|
6
|
+
|
7
|
+
### v0.22.0 / 2023-04-17
|
8
|
+
|
9
|
+
* BREAKING CHANGE: Drop support for EoL Ruby 2.7
|
10
|
+
|
11
|
+
* ADDED: Drop support for EoL Ruby 2.7
|
12
|
+
|
3
13
|
### v0.21.0 / 2023-01-14
|
4
14
|
|
5
15
|
* ADDED: Add request/response hooks to more http clients
|
data/README.md
CHANGED
@@ -30,6 +30,18 @@ OpenTelemetry::SDK.configure do |c|
|
|
30
30
|
end
|
31
31
|
```
|
32
32
|
|
33
|
+
## Enriching http span names
|
34
|
+
|
35
|
+
We surface a hook to easily rename your span.
|
36
|
+
|
37
|
+
The lambda accepts as arguments (request_method, request_path) and returns a string that is set as the span name.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
OpenTelemetry::SDK.configure do |c|
|
41
|
+
c.use 'OpenTelemetry::Instrumentation::Rack', { span_name_formatter: ->(request_method, request_path) { "HTTP #{request_method} #{request_path}" }
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
33
45
|
## Examples
|
34
46
|
|
35
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)
|
@@ -18,6 +18,8 @@ module OpenTelemetry
|
|
18
18
|
!(defined?(::HTTP::Client).nil? || defined?(::HTTP::Connection).nil?)
|
19
19
|
end
|
20
20
|
|
21
|
+
option :span_name_formatter, default: nil, validate: :callable
|
22
|
+
|
21
23
|
def patch
|
22
24
|
::HTTP::Client.prepend(Patches::Client)
|
23
25
|
::HTTP::Connection.prepend(Patches::Connection)
|
@@ -13,6 +13,7 @@ module OpenTelemetry
|
|
13
13
|
def perform(req, options)
|
14
14
|
uri = req.uri
|
15
15
|
request_method = req.verb.to_s.upcase
|
16
|
+
span_name = create_request_span_name(request_method, uri.path)
|
16
17
|
|
17
18
|
attributes = {
|
18
19
|
'http.method' => request_method,
|
@@ -23,7 +24,7 @@ module OpenTelemetry
|
|
23
24
|
'net.peer.port' => uri.port
|
24
25
|
}.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes)
|
25
26
|
|
26
|
-
tracer.in_span(
|
27
|
+
tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
|
27
28
|
OpenTelemetry.propagation.inject(req.headers)
|
28
29
|
super.tap do |response|
|
29
30
|
annotate_span_with_response!(span, response)
|
@@ -33,6 +34,10 @@ module OpenTelemetry
|
|
33
34
|
|
34
35
|
private
|
35
36
|
|
37
|
+
def config
|
38
|
+
OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance.config
|
39
|
+
end
|
40
|
+
|
36
41
|
def annotate_span_with_response!(span, response)
|
37
42
|
return unless response&.status
|
38
43
|
|
@@ -41,6 +46,17 @@ module OpenTelemetry
|
|
41
46
|
span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i)
|
42
47
|
end
|
43
48
|
|
49
|
+
def create_request_span_name(request_method, request_path)
|
50
|
+
if (implementation = config[:span_name_formatter])
|
51
|
+
updated_span_name = implementation.call(request_method, request_path)
|
52
|
+
updated_span_name.is_a?(String) ? updated_span_name : "HTTP #{request_method}"
|
53
|
+
else
|
54
|
+
"HTTP #{request_method}"
|
55
|
+
end
|
56
|
+
rescue StandardError
|
57
|
+
"HTTP #{request_method}"
|
58
|
+
end
|
59
|
+
|
44
60
|
def tracer
|
45
61
|
HTTP::Instrumentation.instance.tracer
|
46
62
|
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.
|
4
|
+
version: 0.23.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: 2023-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.22.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.
|
40
|
+
version: 0.22.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: appraisal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: opentelemetry-test-helpers
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
117
|
+
version: '0.3'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
124
|
+
version: '0.3'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.50.2
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
166
|
+
version: 1.50.2
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: simplecov
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,10 +242,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
242
242
|
licenses:
|
243
243
|
- Apache-2.0
|
244
244
|
metadata:
|
245
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.
|
245
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.0/file/CHANGELOG.md
|
246
246
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/http
|
247
247
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
248
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.
|
248
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-http/0.23.0
|
249
249
|
post_install_message:
|
250
250
|
rdoc_options: []
|
251
251
|
require_paths:
|
@@ -254,14 +254,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
254
254
|
requirements:
|
255
255
|
- - ">="
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version:
|
257
|
+
version: '3.0'
|
258
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
259
|
requirements:
|
260
260
|
- - ">="
|
261
261
|
- !ruby/object:Gem::Version
|
262
262
|
version: '0'
|
263
263
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
264
|
+
rubygems_version: 3.2.33
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: HTTP instrumentation for the OpenTelemetry framework
|