lhc 6.6.0.zipkin.pre → 6.6.0.zipkin.pre.01

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
  SHA1:
3
- metadata.gz: 9ec061c1dd54c6c48e6d3053eeaa5cfde466cbf9
4
- data.tar.gz: 9b01c8475dd3c7002f4fb7f1a23c1e2eb5711566
3
+ metadata.gz: 2b6394b6bd8236ce4d4e08466c9cd9e66fea9530
4
+ data.tar.gz: 7bb72782b609582d68d0dca748cd08f0245cebae
5
5
  SHA512:
6
- metadata.gz: 3332b1305c96357cb69617ae27945b2a09f1621a5733e96d8366d4d07dbebf35fe428937e1e5ca34567f3a3007ff7ae649302afd946f37b7b77138933ec84637
7
- data.tar.gz: bbbebb1d677c39e8f875b25bc494833043cacfa7b15013928153678f10ebf9d0b7dcf0083e12087ba5775c58da98870bd9f8f096970fab65a9057b7ea413c3f4
6
+ metadata.gz: 1b4b679cc13ea4b2434b43f5f1a4272f42584cad6b09c3b488d3c5ac6af997bd277742a2bcb2271e189247ede1a661745c4127cff286cfe82ce25e7b7b656631
7
+ data.tar.gz: a03ac4c46ea0ec3eca544d0ee5595cf13ca9188f12d920aef23fd6c41afc7c861efb70f844a477879bb3af4826876a3f6642b6a7f8a51dce9c19b3bd6c0744f9
data/lib/lhc.rb CHANGED
@@ -112,6 +112,8 @@ module LHC
112
112
  'lhc/response'
113
113
  autoload :Rollbar,
114
114
  'lhc/interceptors/rollbar'
115
+ autoload :ZipkinDistributedTracing,
116
+ 'lhc/interceptors/zipkin_distributed_tracing'
115
117
 
116
118
  require 'lhc/railtie' if defined?(Rails)
117
119
  end
@@ -1,10 +1,11 @@
1
- class LHC::Zipkin < LHC::Interceptor
1
+ class LHC::ZipkinDistributedTracing < LHC::Interceptor
2
2
 
3
3
  def before_request(request)
4
4
  return unless defined?(ZipkinTracer::TraceContainer)
5
5
  container = ZipkinTracer::TraceContainer.current
6
6
  request.headers['X-B3-TraceId'] = container.trace_id.to_s
7
7
  request.headers['X-B3-ParentSpanId'] = container.parent_id.to_s if container.parent_id
8
+ request.headers['X-B3-SpanId'] = container.span_id.to_s
8
9
  request.headers['X-B3-Sampled'] = container.sampled
9
10
  request.headers['X-B3-Flags'] = container.flags
10
11
  end
data/lib/lhc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= "6.6.0.zipkin.pre"
2
+ VERSION ||= "6.6.0.zipkin.pre.01"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHC::ZipkinDistributedTracing do
4
+ before(:all) do
5
+ # defined in spec/support/zipkin.rb
6
+ ::ZipkinTracer::TraceContainer.setup_mock(
7
+ trace_id: 'trace_id',
8
+ parent_id: 'parent_id',
9
+ span_id: 'span_id',
10
+ sampled: 'sampled',
11
+ flags: 'flags'
12
+ )
13
+ end
14
+
15
+ before(:each) do
16
+ LHC.config.interceptors = [described_class]
17
+ LHC.config.endpoint(:local, 'http://local.ch')
18
+ stub_request(:get, 'http://local.ch').to_return(status: 200, body: 'The Website')
19
+ end
20
+
21
+ it 'adds the proper X-B3 headers' do
22
+ headers = LHC.get(:local).request.headers
23
+ expect(headers['X-B3-TraceId']).to eq('trace_id')
24
+ expect(headers['X-B3-ParentSpanId']).to eq('parent_id')
25
+ expect(headers['X-B3-SpanId']).to eq('span_id')
26
+ expect(headers['X-B3-Sampled']).to eq('sampled')
27
+ expect(headers['X-B3-Flags']).to eq('flags')
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module ZipkinTracer
2
+ class TraceContainer
3
+ attr_reader :trace_id, :parent_id, :span_id, :sampled, :flags
4
+ class << self
5
+ attr_accessor :current
6
+
7
+ def setup_mock(trace_id:, parent_id:, span_id:, sampled:, flags:)
8
+ @current = new(trace_id: trace_id, parent_id: parent_id, span_id: span_id, sampled: sampled, flags: flags)
9
+ end
10
+ end
11
+
12
+ def initialize(trace_id:, parent_id:, span_id:, sampled:, flags:)
13
+ @trace_id = trace_id
14
+ @parent_id = parent_id
15
+ @span_id = span_id
16
+ @sampled = sampled
17
+ @flags = flags
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.0.zipkin.pre
4
+ version: 6.6.0.zipkin.pre.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -207,7 +207,7 @@ files:
207
207
  - lib/lhc/interceptors/monitoring.rb
208
208
  - lib/lhc/interceptors/prometheus.rb
209
209
  - lib/lhc/interceptors/rollbar.rb
210
- - lib/lhc/interceptors/zipkin.rb
210
+ - lib/lhc/interceptors/zipkin_distributed_tracing.rb
211
211
  - lib/lhc/railtie.rb
212
212
  - lib/lhc/request.rb
213
213
  - lib/lhc/response.rb
@@ -295,6 +295,7 @@ files:
295
295
  - spec/interceptors/response_competition_spec.rb
296
296
  - spec/interceptors/return_response_spec.rb
297
297
  - spec/interceptors/rollbar/main_spec.rb
298
+ - spec/interceptors/zipkin/distributed_tracing_spec.rb
298
299
  - spec/rails_helper.rb
299
300
  - spec/request/encoding_spec.rb
300
301
  - spec/request/error_handling_spec.rb
@@ -319,6 +320,7 @@ files:
319
320
  - spec/support/fixtures/json/localina_content_ad.json
320
321
  - spec/support/load_json.rb
321
322
  - spec/support/reset_config.rb
323
+ - spec/support/zipkin.rb
322
324
  - spec/timeouts/no_signal_spec.rb
323
325
  - spec/timeouts/timings_spec.rb
324
326
  homepage: https://github.com/local-ch/lhc
@@ -424,6 +426,7 @@ test_files:
424
426
  - spec/interceptors/response_competition_spec.rb
425
427
  - spec/interceptors/return_response_spec.rb
426
428
  - spec/interceptors/rollbar/main_spec.rb
429
+ - spec/interceptors/zipkin/distributed_tracing_spec.rb
427
430
  - spec/rails_helper.rb
428
431
  - spec/request/encoding_spec.rb
429
432
  - spec/request/error_handling_spec.rb
@@ -448,5 +451,6 @@ test_files:
448
451
  - spec/support/fixtures/json/localina_content_ad.json
449
452
  - spec/support/load_json.rb
450
453
  - spec/support/reset_config.rb
454
+ - spec/support/zipkin.rb
451
455
  - spec/timeouts/no_signal_spec.rb
452
456
  - spec/timeouts/timings_spec.rb