lhc 6.6.0.zipkin.pre.03 → 6.6.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
  SHA1:
3
- metadata.gz: b2bc1327e52311ae1c2731d5f722ed845dc8a105
4
- data.tar.gz: f155c109b398297e20f66c12d0fece66d100ca71
3
+ metadata.gz: e8592e613a6a21d6dfc84973f2ab064d9e441246
4
+ data.tar.gz: 73b9069f8c0793e5775c95e754c9160f70fc158a
5
5
  SHA512:
6
- metadata.gz: 0c81778de17035048ae754a841abff3bb1f438b9692344448bf297600e288e338eab5cd990f32733b9ec3dcf0e0637885041b6c6d2ce36222c02658407203d37
7
- data.tar.gz: fe7d4392740d6f7e952e6f2c041ff2fb5edb969e9ded6fe6cc3d7190072bcd7efefb5295c9d21dda98fad434201bfb596b49aa5dd95fb50ef42e3c0323e0c9e2
6
+ metadata.gz: 9fc936bc72038bfb6833307dc9594d7f3e9721f406df6ed9eac1036ea6b45afa3e149d8b333ca1b29c067308ad2c3762e77333c9a3abb9e12b6e77610ff1f82e
7
+ data.tar.gz: ec2dda75db78848b877bd5bcfcc2f88aedb6694aeda1c70eec419c7df6f52dfe684397a30a60aebaf157769916b0ed34c309ca43e0215dfd2cdb9cdbf70b5f43
data/lib/lhc.rb CHANGED
@@ -112,8 +112,6 @@ module LHC
112
112
  'lhc/response'
113
113
  autoload :Rollbar,
114
114
  'lhc/interceptors/rollbar'
115
- autoload :ZipkinDistributedTracing,
116
- 'lhc/interceptors/zipkin_distributed_tracing'
117
115
 
118
116
  require 'lhc/railtie' if defined?(Rails)
119
117
  end
@@ -8,7 +8,7 @@ class LHC::Request
8
8
 
9
9
  TYPHOEUS_OPTIONS ||= [:params, :method, :body, :headers, :follow_location]
10
10
 
11
- attr_accessor :response, :options, :raw, :format, :error_handler, :errors_ignored, :interceptor_environment
11
+ attr_accessor :response, :options, :raw, :format, :error_handler, :errors_ignored
12
12
 
13
13
  def initialize(options, self_executing = true)
14
14
  self.errors_ignored = options.fetch(:ignored_errors, [])
@@ -19,7 +19,6 @@ class LHC::Request
19
19
  self.iprocessor = LHC::InterceptorProcessor.new(self)
20
20
  self.raw = create_request
21
21
  self.format = options.delete('format') || LHC::Formats::JSON.new
22
- self.interceptor_environment ||= {}
23
22
  iprocessor.intercept(:before_request, self)
24
23
  raw.run if self_executing && !response
25
24
  end
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= "6.6.0.zipkin.pre.03"
2
+ VERSION ||= "6.6.0"
3
3
  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.03
4
+ version: 6.6.0
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-27 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -207,7 +207,6 @@ 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_distributed_tracing.rb
211
210
  - lib/lhc/railtie.rb
212
211
  - lib/lhc/request.rb
213
212
  - lib/lhc/response.rb
@@ -295,7 +294,6 @@ files:
295
294
  - spec/interceptors/response_competition_spec.rb
296
295
  - spec/interceptors/return_response_spec.rb
297
296
  - spec/interceptors/rollbar/main_spec.rb
298
- - spec/interceptors/zipkin/distributed_tracing_spec.rb
299
297
  - spec/rails_helper.rb
300
298
  - spec/request/encoding_spec.rb
301
299
  - spec/request/error_handling_spec.rb
@@ -320,7 +318,6 @@ files:
320
318
  - spec/support/fixtures/json/localina_content_ad.json
321
319
  - spec/support/load_json.rb
322
320
  - spec/support/reset_config.rb
323
- - spec/support/zipkin.rb
324
321
  - spec/timeouts/no_signal_spec.rb
325
322
  - spec/timeouts/timings_spec.rb
326
323
  homepage: https://github.com/local-ch/lhc
@@ -338,9 +335,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
338
335
  version: 2.0.0
339
336
  required_rubygems_version: !ruby/object:Gem::Requirement
340
337
  requirements:
341
- - - ">"
338
+ - - ">="
342
339
  - !ruby/object:Gem::Version
343
- version: 1.3.1
340
+ version: '0'
344
341
  requirements:
345
342
  - Ruby >= 2.0.0
346
343
  rubyforge_project:
@@ -426,7 +423,6 @@ test_files:
426
423
  - spec/interceptors/response_competition_spec.rb
427
424
  - spec/interceptors/return_response_spec.rb
428
425
  - spec/interceptors/rollbar/main_spec.rb
429
- - spec/interceptors/zipkin/distributed_tracing_spec.rb
430
426
  - spec/rails_helper.rb
431
427
  - spec/request/encoding_spec.rb
432
428
  - spec/request/error_handling_spec.rb
@@ -451,6 +447,5 @@ test_files:
451
447
  - spec/support/fixtures/json/localina_content_ad.json
452
448
  - spec/support/load_json.rb
453
449
  - spec/support/reset_config.rb
454
- - spec/support/zipkin.rb
455
450
  - spec/timeouts/no_signal_spec.rb
456
451
  - spec/timeouts/timings_spec.rb
@@ -1,68 +0,0 @@
1
- require 'uri'
2
-
3
- class LHC::ZipkinDistributedTracing < LHC::Interceptor
4
-
5
- def before_request(request)
6
- return unless defined?(ZipkinTracer::TraceContainer) && ZipkinTracer::TraceContainer.current && defined?(Trace)
7
- trace_id = ZipkinTracer::TraceGenerator.new.next_trace_id
8
- ZipkinTracer::TraceContainer.with_trace_id(trace_id) do
9
- b3_headers.each do |method, header|
10
- request.headers[header] = trace_id.send(method).to_s
11
- end
12
- trace!(request, trace_id) if ::Trace.tracer && trace_id.sampled?
13
- end
14
- end
15
-
16
- def after_response(response)
17
- if span = response.request.interceptor_environment[:zipkin_span]
18
- record_response_tags(span, response)
19
- end
20
- span.record(Trace::Annotation::CLIENT_RECV, local_endpoint)
21
- Trace.tracer.end_span(span)
22
- end
23
- private
24
-
25
- SERVER_ADDRESS_SPECIAL_VALUE = '1'.freeze
26
-
27
- def b3_headers
28
- {
29
- trace_id: 'X-B3-TraceId',
30
- parent_id: 'X-B3-ParentSpanId',
31
- span_id: 'X-B3-SpanId',
32
- sampled: 'X-B3-Sampled',
33
- flags: 'X-B3-Flags'
34
- }
35
- end
36
-
37
- def trace!(request, trace_id)
38
- url_string = request.raw.url
39
- url = URI(url_string)
40
- service_name = url.host
41
- span = Trace.tracer.start_span(trace_id, request.method.to_s.downcase)
42
- # annotate with method (GET/POST/etc.) and uri path
43
- span.record_tag(Trace::BinaryAnnotation::PATH, url.path, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
44
- span.record_tag(Trace::BinaryAnnotation::SERVER_ADDRESS, SERVER_ADDRESS_SPECIAL_VALUE, Trace::BinaryAnnotation::Type::BOOL, remote_endpoint(url, service_name))
45
- span.record(Trace::Annotation::CLIENT_SEND, local_endpoint)
46
- # store the span in the datum hash so it can be used in the response_call
47
- request.interceptor_environment[:zipkin_span] = span
48
- rescue ArgumentError, URI::Error => e
49
- # Ignore URI errors, don't trace if there is no URI
50
- end
51
-
52
- def local_endpoint
53
- Trace.default_endpoint # The rack middleware set this up for us.
54
- end
55
-
56
- def remote_endpoint(url, service_name)
57
- Trace::Endpoint.remote_endpoint(url, service_name, local_endpoint.ip_format) # The endpoint we are calling.
58
- end
59
-
60
- def record_response_tags(span, response)
61
- status = response.code.to_s
62
- span.record_tag(Trace::BinaryAnnotation::STATUS, status, Trace::BinaryAnnotation::Type::STRING, local_endpoint)
63
- if !response.success?
64
- span.record_tag(Trace::BinaryAnnotation::ERROR, status,
65
- Trace::BinaryAnnotation::Type::STRING, local_endpoint)
66
- end
67
- end
68
- end
@@ -1,29 +0,0 @@
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
@@ -1,20 +0,0 @@
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