mnemosyne-ruby 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +6 -1
- data/lib/mnemosyne/middleware/faraday.rb +35 -0
- data/lib/mnemosyne/probes/faraday/base.rb +16 -30
- data/lib/mnemosyne/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac987a42c8acad894e9ba6f4a7a8f82978a070a814f1934740e972d872319483
|
4
|
+
data.tar.gz: fc1fce9f2aa11e6f01dc826a70d5130791191d4d6750a8f65239a70bd3c33c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3089578f4a14216d8f50d0aac9f2af6ef177051181629ee8f5956b5874f9396dca9723670bc5eb776b7a8cb0f24567c3a48714be5bf3b972166d9bda5371f41f
|
7
|
+
data.tar.gz: bc4c72f330ba74aec138fb31dcaa4acb9c53f426cda98c34abae7780fd30c076d0d39ce6f804497b7d40a5bc5dac659df798c57ecb7f692084c56ae087d2aca3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.7.1] - 2019-06-15
|
9
|
+
### Fixed
|
10
|
+
- Reworked Faraday probe to not override connection middleware stack
|
11
|
+
|
8
12
|
## [1.7.0] - 2019-05-21
|
9
13
|
### Added
|
10
14
|
- Restify probe: Attach HTTP response status (#12, #13)
|
@@ -78,7 +82,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
78
82
|
### Added
|
79
83
|
- Add platform identifier
|
80
84
|
|
81
|
-
[
|
85
|
+
[unreleased]: https://github.com/:mnemosyne-mon/mnemosyne-ruby/compare/v1.7.1...HEAD
|
86
|
+
[1.7.1]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.7.0...v1.7.1
|
82
87
|
[1.7.0]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.6.2...v1.7.0
|
83
88
|
[1.6.2]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.6.1...v1.6.2
|
84
89
|
[1.6.1]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.6.0...v1.6.1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module Mnemosyne
|
6
|
+
module Middleware
|
7
|
+
class Faraday < ::Faraday::Middleware
|
8
|
+
def initialize(app)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
trace = ::Mnemosyne::Instrumenter.current_trace
|
14
|
+
|
15
|
+
return @app.call(env) unless trace
|
16
|
+
|
17
|
+
span = ::Mnemosyne::Span.new 'external.http.faraday', \
|
18
|
+
meta: {url: env[:url].to_s, method: env[:method]}
|
19
|
+
|
20
|
+
span.start!
|
21
|
+
|
22
|
+
env[:request_headers].merge!({
|
23
|
+
'X-Mnemosyne-Transaction' => trace.transaction,
|
24
|
+
'X-Mnemosyne-Origin' => span.uuid,
|
25
|
+
}.reject {|_, v| v.nil? })
|
26
|
+
|
27
|
+
@app.call(env).on_complete do |env|
|
28
|
+
span.meta[:status] = env[:status]
|
29
|
+
|
30
|
+
trace << span.finish!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,41 +6,27 @@ module Mnemosyne
|
|
6
6
|
module Base
|
7
7
|
class Probe < ::Mnemosyne::Probe
|
8
8
|
def setup
|
9
|
-
|
10
|
-
builder: ::Faraday::RackBuilder.new do |faraday|
|
11
|
-
faraday.use Probe::Middleware
|
12
|
-
faraday.request :url_encoded
|
13
|
-
faraday.adapter ::Faraday.default_adapter
|
14
|
-
end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
class Middleware
|
19
|
-
def initialize(app)
|
20
|
-
@app = app
|
21
|
-
end
|
22
|
-
|
23
|
-
def call(env)
|
24
|
-
trace = ::Mnemosyne::Instrumenter.current_trace
|
25
|
-
|
26
|
-
return @app.call(env) unless trace
|
9
|
+
require 'mnemosyne/middleware/faraday'
|
27
10
|
|
28
|
-
|
29
|
-
|
11
|
+
::Faraday::Middleware.register_middleware \
|
12
|
+
mnemosyne: ::Mnemosyne::Middleware::Faraday
|
30
13
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
'X-Mnemosyne-Transaction' => trace.transaction,
|
35
|
-
'X-Mnemosyne-Origin' => span.uuid,
|
36
|
-
}.reject {|_, v| v.nil? })
|
37
|
-
|
38
|
-
@app.call(env).on_complete do |env|
|
39
|
-
span.meta[:status] = env[:status]
|
14
|
+
::Faraday::RackBuilder.prepend Extension
|
15
|
+
end
|
16
|
+
end
|
40
17
|
|
41
|
-
|
18
|
+
module Extension
|
19
|
+
def lock!
|
20
|
+
if !@handlers.include?('Mnemosyne::Middleware::Faraday')
|
21
|
+
if respond_to?(:is_adapter?, true) &&
|
22
|
+
(idx = @handlers.find_index {|h| is_adapter?(h) })
|
23
|
+
insert(idx, ::Mnemosyne::Middleware::Faraday)
|
24
|
+
else
|
25
|
+
use(::Mnemosyne::Middleware::Faraday)
|
42
26
|
end
|
43
27
|
end
|
28
|
+
|
29
|
+
super
|
44
30
|
end
|
45
31
|
end
|
46
32
|
end
|
data/lib/mnemosyne/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mnemosyne-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/mnemosyne/instrumenter.rb
|
83
83
|
- lib/mnemosyne/logging.rb
|
84
84
|
- lib/mnemosyne/middleware/acfs.rb
|
85
|
+
- lib/mnemosyne/middleware/faraday.rb
|
85
86
|
- lib/mnemosyne/middleware/rack.rb
|
86
87
|
- lib/mnemosyne/middleware/sidekiq.rb
|
87
88
|
- lib/mnemosyne/probe.rb
|