opentelemetry-instrumentation-faraday 0.24.7 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/opentelemetry/instrumentation/faraday/instrumentation.rb +11 -6
- data/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb +15 -12
- data/lib/opentelemetry/instrumentation/faraday/patches/connection.rb +1 -1
- data/lib/opentelemetry/instrumentation/faraday/version.rb +1 -1
- metadata +9 -10
- data/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef531ecfdcc07ba765a21743d3787b8d6de244b2b371241cd5121d775c7c679b
|
4
|
+
data.tar.gz: 33df6f2dd61589ffdf001c3577679f944b52ff2d287fcf6cfc456f3de3f28cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 287d1fd9d8468da07f37b2ba1c2af2292a88f0fc34bd581111c4dbd7d5e375d9f72260de1b10ec74ff690bf2913d73c2e4da829c047df05472e12aa2bc2cc858
|
7
|
+
data.tar.gz: 657f53bae563c8f50ae349e30e56411292f2e5be8a7bc910eb4506aa8eff8c6f3df6f8e46be085de9032869439ed68d3ff203180ae101addb4840a4800e2b6fe
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-faraday
|
2
2
|
|
3
|
+
### v0.25.0 / 2025-01-07
|
4
|
+
|
5
|
+
* ADDED: Faraday Minimum v1.0
|
6
|
+
|
7
|
+
### v0.24.8 / 2024-12-17
|
8
|
+
|
9
|
+
* FIXED: Share Faraday Attrs with Adapter Spans
|
10
|
+
|
3
11
|
### v0.24.7 / 2024-11-26
|
4
12
|
|
5
13
|
* CHANGED: Performance Freeze all range objects #1222
|
@@ -10,12 +10,18 @@ module OpenTelemetry
|
|
10
10
|
# The Instrumentation class contains logic to detect and install the Faraday
|
11
11
|
# instrumentation
|
12
12
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
13
|
+
MINIMUM_VERSION = Gem::Version.new('1.0')
|
14
|
+
|
13
15
|
install do |_config|
|
14
16
|
require_dependencies
|
15
17
|
register_tracer_middleware
|
16
18
|
use_middleware_by_default
|
17
19
|
end
|
18
20
|
|
21
|
+
compatible do
|
22
|
+
gem_version >= MINIMUM_VERSION
|
23
|
+
end
|
24
|
+
|
19
25
|
present do
|
20
26
|
defined?(::Faraday)
|
21
27
|
end
|
@@ -25,10 +31,13 @@ module OpenTelemetry
|
|
25
31
|
|
26
32
|
private
|
27
33
|
|
34
|
+
def gem_version
|
35
|
+
Gem::Version.new(::Faraday::VERSION)
|
36
|
+
end
|
37
|
+
|
28
38
|
def require_dependencies
|
29
39
|
require_relative 'middlewares/tracer_middleware'
|
30
40
|
require_relative 'patches/connection'
|
31
|
-
require_relative 'patches/rack_builder'
|
32
41
|
end
|
33
42
|
|
34
43
|
def register_tracer_middleware
|
@@ -38,11 +47,7 @@ module OpenTelemetry
|
|
38
47
|
end
|
39
48
|
|
40
49
|
def use_middleware_by_default
|
41
|
-
|
42
|
-
::Faraday::Connection.prepend(Patches::Connection)
|
43
|
-
else
|
44
|
-
::Faraday::RackBuilder.prepend(Patches::RackBuilder)
|
45
|
-
end
|
50
|
+
::Faraday::Connection.prepend(Patches::Connection)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
@@ -33,31 +33,34 @@ module OpenTelemetry
|
|
33
33
|
attributes = span_creation_attributes(
|
34
34
|
http_method: http_method, url: env.url, config: config
|
35
35
|
)
|
36
|
-
tracer.in_span(
|
37
|
-
"HTTP #{http_method}", attributes: attributes, kind: config.fetch(:span_kind)
|
38
|
-
) do |span|
|
39
|
-
OpenTelemetry.propagation.inject(env.request_headers)
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _|
|
38
|
+
tracer.in_span(
|
39
|
+
"HTTP #{http_method}", attributes: attrs, kind: config.fetch(:span_kind)
|
40
|
+
) do |span|
|
41
|
+
OpenTelemetry.propagation.inject(env.request_headers)
|
44
42
|
|
45
|
-
|
43
|
+
app.call(env).on_complete { |resp| trace_response(span, resp.status) }
|
44
|
+
rescue ::Faraday::Error => e
|
45
|
+
trace_response(span, e.response[:status]) if e.response
|
46
|
+
|
47
|
+
raise
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
private
|
50
53
|
|
51
54
|
def span_creation_attributes(http_method:, url:, config:)
|
52
|
-
|
55
|
+
attrs = {
|
53
56
|
'http.method' => http_method,
|
54
57
|
'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s),
|
55
58
|
'faraday.adapter.name' => app.class.name
|
56
59
|
}
|
57
|
-
|
58
|
-
|
60
|
+
attrs['net.peer.name'] = url.host if url.host
|
61
|
+
attrs['peer.service'] = config[:peer_service] if config[:peer_service]
|
59
62
|
|
60
|
-
|
63
|
+
attrs.merge!(
|
61
64
|
OpenTelemetry::Common::HTTP::ClientContext.attributes
|
62
65
|
)
|
63
66
|
end
|
@@ -13,7 +13,7 @@ module OpenTelemetry
|
|
13
13
|
module Connection
|
14
14
|
# Wraps Faraday::Connection#initialize:
|
15
15
|
# https://github.com/lostisland/faraday/blob/ff9dc1d1219a1bbdba95a9a4cf5d135b97247ee2/lib/faraday/connection.rb#L62-L92
|
16
|
-
def initialize(
|
16
|
+
def initialize(...)
|
17
17
|
super.tap do
|
18
18
|
use(:open_telemetry) unless builder.handlers.any? do |handler|
|
19
19
|
handler.klass == Middlewares::TracerMiddleware
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
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:
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.69.1
|
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: 1.
|
124
|
+
version: 1.69.1
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-performance
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,17 +195,16 @@ files:
|
|
195
195
|
- lib/opentelemetry/instrumentation/faraday/instrumentation.rb
|
196
196
|
- lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb
|
197
197
|
- lib/opentelemetry/instrumentation/faraday/patches/connection.rb
|
198
|
-
- lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb
|
199
198
|
- lib/opentelemetry/instrumentation/faraday/version.rb
|
200
199
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
201
200
|
licenses:
|
202
201
|
- Apache-2.0
|
203
202
|
metadata:
|
204
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.
|
203
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.25.0/file/CHANGELOG.md
|
205
204
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/faraday
|
206
205
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
207
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.
|
208
|
-
post_install_message:
|
206
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-faraday/0.25.0
|
207
|
+
post_install_message:
|
209
208
|
rdoc_options: []
|
210
209
|
require_paths:
|
211
210
|
- lib
|
@@ -221,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
220
|
version: '0'
|
222
221
|
requirements: []
|
223
222
|
rubygems_version: 3.2.33
|
224
|
-
signing_key:
|
223
|
+
signing_key:
|
225
224
|
specification_version: 4
|
226
225
|
summary: Faraday instrumentation for the OpenTelemetry framework
|
227
226
|
test_files: []
|
@@ -1,25 +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 Faraday
|
10
|
-
module Patches
|
11
|
-
# Module to be prepended to force Faraday to use the middleware by
|
12
|
-
# default so the user doesn't have to call `use` for every connection.
|
13
|
-
module RackBuilder
|
14
|
-
def adapter(*args)
|
15
|
-
use(:open_telemetry) unless @handlers.any? do |handler|
|
16
|
-
handler.klass == Faraday::Middlewares::TracerMiddleware
|
17
|
-
end
|
18
|
-
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|