faraday-zipkin 0.1.0 → 0.1.1
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 +8 -8
- data/lib/faraday/zipkin.rb +4 -1
- data/lib/faraday/zipkin/version.rb +1 -1
- data/spec/zipkin_trace_headers_spec.rb +18 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjJkNWExZDIwMmE4NDZlYzY4YmViNWFmNDIyZTJiYTVhMThkZWVlMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzg0MTAyNDU0YmQ0NGJkMGI5NzUxMWFiZjQ3NzdhNWFjNGRiYzk0Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODQ3ZDI4ZDM4NjQwMTQ0NWViOGNlOGJjZGMxZTFlYmMzMjI2NWI1YmQxNjlk
|
10
|
+
OGQ4NTE3Y2JlMmI2Y2ExODU4YzAwZGM5YWFjMjNjYzcyYjA4MThlMmE3YjRk
|
11
|
+
YzgwYjZkZDQ2ZDM2NGY3NWUyMWI3MzI2YmVhOTkwNmFiMmZkMjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmRhZGRlN2U4OGVmMTM2NDEyYWZiOTA3NGUyMzFkNGUzZTQ3OWRmZGYxYWMy
|
14
|
+
ODU0ODllNjhhMjM0NGNlM2VmNjZkZjkwMzUyNDMxZTEyOTI5YWU1ZDA3OGE2
|
15
|
+
ZGYwYTI1NWZmMTU0MmE5MjBjYWRiMDQ4NTRmYjZhNjJhMTdjZDQ=
|
data/lib/faraday/zipkin.rb
CHANGED
@@ -21,7 +21,10 @@ module Faraday
|
|
21
21
|
|
22
22
|
def call(env)
|
23
23
|
trace_id = ::Trace.id
|
24
|
-
|
24
|
+
|
25
|
+
# handle either a URI object (passed by Faraday v0.8.x in testing), or something string-izable
|
26
|
+
host = env[:url].respond_to?(:host) ? env[:url].host : URI.parse(env[:url].to_s).host
|
27
|
+
|
25
28
|
::Trace.push(trace_id.next_id) do
|
26
29
|
::Trace.record(::Trace::Annotation.new(::Trace::Annotation::CLIENT_SEND, host))
|
27
30
|
B3_HEADERS.each do |method, header|
|
@@ -2,9 +2,9 @@ describe Faraday::Zipkin::TraceHeaders do
|
|
2
2
|
let(:middleware) { described_class.new(lambda{|env| env}) }
|
3
3
|
let(:hostname) { 'service.example.com' }
|
4
4
|
|
5
|
-
def process(body, headers={})
|
5
|
+
def process(body, url, headers={})
|
6
6
|
env = {
|
7
|
-
:url =>
|
7
|
+
:url => url,
|
8
8
|
:body => body,
|
9
9
|
:request_headers => Faraday::Utils::Headers.new(headers),
|
10
10
|
}
|
@@ -16,7 +16,7 @@ describe Faraday::Zipkin::TraceHeaders do
|
|
16
16
|
match { |actual| actual.value == v && actual.host == h }
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
shared_examples 'can make requests' do
|
20
20
|
context 'with tracing id' do
|
21
21
|
let(:trace_id) { ::Trace::TraceId.new(1, 2, 3, true) }
|
22
22
|
|
@@ -27,7 +27,7 @@ describe Faraday::Zipkin::TraceHeaders do
|
|
27
27
|
|
28
28
|
result = nil
|
29
29
|
::Trace.push(trace_id) do
|
30
|
-
result = process('')
|
30
|
+
result = process('', url)
|
31
31
|
end
|
32
32
|
expect(result[:request_headers]['X-B3-TraceId']).to eq('0000000000000001')
|
33
33
|
expect(result[:request_headers]['X-B3-ParentSpanId']).to eq('0000000000000003')
|
@@ -39,7 +39,7 @@ describe Faraday::Zipkin::TraceHeaders do
|
|
39
39
|
|
40
40
|
context 'without tracing id' do
|
41
41
|
it 'generates a new ID, and sets the X-B3 request headers' do
|
42
|
-
result = process('')
|
42
|
+
result = process('', url)
|
43
43
|
expect(result[:request_headers]['X-B3-TraceId']).to match(/^\h{16}$/)
|
44
44
|
expect(result[:request_headers]['X-B3-ParentSpanId']).to match(/^\h{16}$/)
|
45
45
|
expect(result[:request_headers]['X-B3-SpanId']).to match(/^\h{16}$/)
|
@@ -47,4 +47,17 @@ describe Faraday::Zipkin::TraceHeaders do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
context 'request with string URL' do
|
52
|
+
let(:url) { "https://#{hostname}/some/path/here" }
|
53
|
+
|
54
|
+
include_examples 'can make requests'
|
55
|
+
end
|
56
|
+
|
57
|
+
# in testing, Faraday v0.8.x passes a URI object rather than a string
|
58
|
+
context 'request with pre-parsed URL' do
|
59
|
+
let(:url) { URI.parse("https://#{hostname}/some/path/here") }
|
60
|
+
|
61
|
+
include_examples 'can make requests'
|
62
|
+
end
|
50
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-zipkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ariel Salomon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|