zipkin-tracer 0.33.0 → 0.34.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
  SHA256:
3
- metadata.gz: 0da9730b55f7aa56b8b1080b4de79c731e6e09997e1c8ed958f0954d9f9acd70
4
- data.tar.gz: 5a780069dfa04fe86a86fd805c89f00db11ba5af1f29057625b90d6aa03adf87
3
+ metadata.gz: ba81449b69065fcd0ffcca18f0750e49826896cc8321c3a18d2e6df22a25cd27
4
+ data.tar.gz: 861e0bfb101b56935c0488c34d3db34154226b2625067c3db7b88e8bb168bfeb
5
5
  SHA512:
6
- metadata.gz: 95aab26491cde2e63b9d1e8a304b0edbac6658ee524143b202e53486a5f5552e738749fd16b274b74e7fc894c0d8bc30097e5bca2a5a26441815df662c389b3d
7
- data.tar.gz: 8826d81412e97b9f0dd1c551bebd959b56782a690a76779d7da81169259c6bcad14cb8a5674c92d7fc6384ef55f5db932aad6d601628339c056439279632f5c7
6
+ metadata.gz: 5f136b2d49f70678fdbb768707418ec099c46e5dceef84efb83d063f057927e1cdd2ff7e750ea3f31a3b0a0a5a02869996131d24b35108ef178711a53f91bc7a
7
+ data.tar.gz: 78dfc19eee7a3f4b9b77ef8a980783cf2fc79e3087d406c7e89ac1e915cacd941f44b295f40921ca1966ccafa6688b71e5d94b1ef8a4969c4312bd5c408fd44c
@@ -1,17 +1,18 @@
1
1
  module ZipkinTracer
2
-
3
2
  # Useful methods on the Application we are instrumenting
4
3
  class Application
5
- # If the request is not valid for this service, we do not what to trace it.
6
- def self.routable_request?(path_info, http_method)
4
+ # Determines if our framework knows whether the request will be routed to a controller
5
+ def self.routable_request?(env)
7
6
  return true unless defined?(Rails) # If not running on a Rails app, we can't verify if it is invalid
7
+ path_info = env[ZipkinTracer::RackHandler::PATH_INFO]
8
+ http_method = env[ZipkinTracer::RackHandler::REQUEST_METHOD]
8
9
  Rails.application.routes.recognize_path(path_info, method: http_method)
9
10
  true
10
11
  rescue ActionController::RoutingError
11
12
  false
12
13
  end
13
14
 
14
- def self.get_route(env)
15
+ def self.route(env)
15
16
  return nil unless defined?(Rails)
16
17
  stub_env = {
17
18
  "PATH_INFO" => env[ZipkinTracer::RackHandler::PATH_INFO],
@@ -27,7 +28,7 @@ module ZipkinTracer
27
28
  end
28
29
 
29
30
  def self.logger
30
- if defined?(Rails.logger) # If we happen to be inside a Rails app, use its logger
31
+ if defined?(Rails.logger)
31
32
  Rails.logger
32
33
  else
33
34
  Logger.new(STDOUT)
@@ -26,8 +26,6 @@ module ZipkinTracer
26
26
  @sample_rate = config[:sample_rate] || DEFAULTS[:sample_rate]
27
27
  # A block of code which can be called to do extra annotations of traces
28
28
  @annotate_plugin = config[:annotate_plugin] # call for trace annotation
29
- @filter_plugin = config[:filter_plugin] # skip tracing if returns false
30
- @whitelist_plugin = config[:whitelist_plugin] # force sampling if returns true
31
29
  # A block of code which can be called to skip traces. Skip tracing if returns false
32
30
  @filter_plugin = config[:filter_plugin]
33
31
  # A block of code which can be called to force sampling. Forces sampling if returns true
@@ -37,7 +37,6 @@ module ZipkinTracer
37
37
 
38
38
  private
39
39
 
40
- SERVER_ADDRESS_SPECIAL_VALUE = true
41
40
  STATUS_ERROR_REGEXP = /\A(4.*|5.*)\z/.freeze
42
41
 
43
42
  def b3_headers
@@ -25,10 +25,8 @@ module ZipkinTracer
25
25
 
26
26
  private
27
27
 
28
- SERVER_ADDRESS_SPECIAL_VALUE = true
29
28
  STATUS_ERROR_REGEXP = /\A(4.*|5.*)\z/.freeze
30
29
 
31
-
32
30
  def b3_headers
33
31
  {
34
32
  trace_id: 'X-B3-TraceId',
@@ -25,7 +25,7 @@ module ZipkinTracer
25
25
  zipkin_env = ZipkinEnv.new(env, @config)
26
26
  trace_id = zipkin_env.trace_id
27
27
  TraceContainer.with_trace_id(trace_id) do
28
- if !trace_id.sampled? || !routable_request?(env)
28
+ if !trace_id.sampled?
29
29
  @app.call(env)
30
30
  else
31
31
  @tracer.with_new_span(trace_id, span_name(env)) do |span|
@@ -37,16 +37,8 @@ module ZipkinTracer
37
37
 
38
38
  private
39
39
 
40
- def routable_request?(env)
41
- Application.routable_request?(env[PATH_INFO], env[REQUEST_METHOD])
42
- end
43
-
44
- def route(env)
45
- Application.get_route(env)
46
- end
47
-
48
40
  def span_name(env)
49
- "#{env[REQUEST_METHOD].to_s.downcase} #{route(env)}".strip
41
+ "#{env[REQUEST_METHOD].to_s.downcase} #{Application.route(env)}".strip
50
42
  end
51
43
 
52
44
  def annotate_plugin(span, env, status, response_headers, response_body)
@@ -56,7 +48,6 @@ module ZipkinTracer
56
48
  def trace!(span, zipkin_env, &block)
57
49
  trace_request_information(span, zipkin_env)
58
50
  span.kind = Trace::Span::Kind::SERVER
59
- span.record('whitelisted') if zipkin_env.force_sample?
60
51
  status, headers, body = yield
61
52
  ensure
62
53
  annotate_plugin(span, zipkin_env.env, status, headers, body)
@@ -20,10 +20,6 @@ module ZipkinTracer
20
20
  @called_with_zipkin_headers ||= B3_REQUIRED_HEADERS.all? { |key| @env.key?(key) }
21
21
  end
22
22
 
23
- def force_sample?
24
- @force_sample ||= @config.whitelist_plugin && @config.whitelist_plugin.call(@env)
25
- end
26
-
27
23
  private
28
24
 
29
25
  B3_REQUIRED_HEADERS = %w(HTTP_X_B3_TRACEID HTTP_X_B3_SPANID).freeze
@@ -61,15 +57,24 @@ module ZipkinTracer
61
57
  end
62
58
 
63
59
  def sampled_header_value(parent_trace_sampled)
64
- if parent_trace_sampled # A service upstream decided this goes in all the way
60
+ if parent_trace_sampled # A service upstream decided this goes in all the way
65
61
  parent_trace_sampled
66
62
  else
67
- new_sampled_header_value(force_sample? || current_trace_sampled? && !filtered?)
63
+ new_sampled_header_value(force_sample? || current_trace_sampled? && !filtered? && routable_request?)
68
64
  end
69
65
  end
70
66
 
67
+ def force_sample?
68
+ @config.whitelist_plugin && @config.whitelist_plugin.call(@env)
69
+ end
70
+
71
71
  def filtered?
72
72
  @config.filter_plugin && !@config.filter_plugin.call(@env)
73
73
  end
74
+
75
+ def routable_request?
76
+ Application.routable_request?(@env)
77
+ end
78
+
74
79
  end
75
80
  end
@@ -1,3 +1,3 @@
1
1
  module ZipkinTracer
2
- VERSION = '0.33.0'.freeze
2
+ VERSION = '0.34.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipkin-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.0
4
+ version: 0.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franklin Hu
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-03-08 00:00:00.000000000 Z
16
+ date: 2019-03-28 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: faraday
@@ -199,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
- version: 2.0.0
202
+ version: 2.3.0
203
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  requirements:
205
205
  - - ">="