rubyzipkin 0.4.1 → 0.4.2

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.
data/lib/rubyzipkin.rb CHANGED
@@ -8,6 +8,7 @@ require 'rubyzipkin/headers'
8
8
  require 'rubyzipkin/metadata_logger'
9
9
  require 'rubyzipkin/tracesampler'
10
10
  require 'rubyzipkin/trace_filter'
11
+ require 'rubyzipkin/permanent_header_filter'
11
12
 
12
13
 
13
14
  module RubyZipkin extend self
@@ -31,17 +32,21 @@ module RubyZipkin extend self
31
32
  def call(env)
32
33
  begin
33
34
  ::Trace.default_endpoint = ::Trace.default_endpoint.with_service_name(@service_name + "_#{normalized_uri(env['PATH_INFO'])}")
34
-
35
35
  set_sample_rate(env)
36
36
  trace_id = get_or_create_trace_id(env)
37
37
  env[ZipkinTraceHeader::PARENT_SPAN_ID] = @spanid
38
38
  env[ZipkinTraceHeader::TRACE_ID] = @tid
39
39
 
40
- @status, @headers, @response = @app.call(env)
40
+ rescue => e
41
+ $stderr.puts "ZIPKIN [ERR] #{e}"
42
+ end
41
43
 
44
+ begin
45
+ @status, @headers, @response = @app.call(env)
42
46
  tracing_filter(trace_id, env, @headers)
43
47
  rescue => e
44
- #Tracing errors shouldn't block a request.
48
+ # we want to do the call even if zipkin fails
49
+ $stderr.puts "ZIPKIN [ERR] #{e} \n\n\n #{e.backtrace}"
45
50
  end
46
51
  [@status, @headers, @response]
47
52
  end
@@ -60,6 +65,7 @@ module RubyZipkin extend self
60
65
  private
61
66
  def tracing_filter(trace_id, env, headers=nil)
62
67
  if RubyZipkin::TraceFilter.UriFilterMatches?(normalized_uri(env["PATH_INFO"]), @uri_filter_list)
68
+ "ZIPKIN: path matches filter. returning"
63
69
  return
64
70
  end
65
71
  @lock.synchronize do
@@ -78,9 +84,10 @@ module RubyZipkin extend self
78
84
  yield if block_given?
79
85
  ensure
80
86
  @lock.synchronize do
87
+
81
88
  ::Trace.record(::Trace::Annotation.new(::Trace::Annotation::SERVER_SEND, ::Trace.default_endpoint))
82
89
  add_referer(env)
83
- ::Trace.pop
90
+ p = ::Trace.pop
84
91
  end
85
92
  end
86
93
 
@@ -99,8 +106,9 @@ module RubyZipkin extend self
99
106
  end
100
107
 
101
108
  def trace_post_data(content)
109
+
102
110
  # Slightly large size cap to the request input to accomodate larger JSON bodies.
103
- MetadataLogger.log('HTTP_REQUEST INPUT', content.to_s, 2048)
111
+ MetadataLogger.log('HTTP_REQUEST_INPUT', content.to_s, 1024)
104
112
  end
105
113
 
106
114
  def trace_hash(content)
@@ -113,6 +121,11 @@ module RubyZipkin extend self
113
121
  end
114
122
  end
115
123
 
124
+ # Generates a trace ID set in Finagle's format
125
+ # * @param _traceId The id for this request.
126
+ # * @param _parentId The id for the request one step up the service stack.
127
+ # * @param spanId The id for this particular request
128
+ # * @param _sampled Should we sample this request or not? True means sample, false means don't.
116
129
  def get_or_create_trace_id(env)
117
130
 
118
131
  if env[ZipkinTraceHeader::TRACE_ID].nil? or env[ZipkinTraceHeader::TRACE_ID].to_s.empty?
@@ -9,9 +9,12 @@ module RubyZipkin
9
9
  # since logging can ve quite extensive, we set a cap for the max size in bytes for a trace header
10
10
  def self.log(key, value, max_size_bytes = 512)
11
11
  if key.to_s == "action_controller.rescue.request" || key.to_s == "action_controller.rescue.response"
12
- ::Trace.record(::Trace::BinaryAnnotation.new(key, value.as_json.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint))
12
+ ann = ::Trace::BinaryAnnotation.new(key, value.as_json.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint)
13
+ puts ann.to_s
14
+ ::Trace.record(ann)
13
15
  else
14
- ::Trace.record(::Trace::BinaryAnnotation.new(key, value.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint))
16
+ ann = ::Trace::BinaryAnnotation.new(key, value.to_s[0..max_size_bytes], "STRING", ::Trace.default_endpoint)
17
+ ::Trace.record(ann)
15
18
  end
16
19
  end
17
20
 
@@ -12,7 +12,10 @@ module RubyZipkin
12
12
  "rack.session.options",
13
13
  "rack.request.cookie_hash",
14
14
  "rack.request.cookie_string",
15
- "rack.request.form_vars"
15
+ "rack.request.form_vars",
16
+ "action_controller.rescue",
17
+ "action_controller.rescue.request",
18
+ "action_controller.rescue.response"
16
19
  ]
17
20
  end
18
21
  end
@@ -12,7 +12,7 @@ module RubyZipkin
12
12
  end
13
13
 
14
14
  keyword_blacklist.each do |key|
15
- if uri.to_s.match key or uri.to
15
+ if uri.to_s.match(key)
16
16
  return true
17
17
  end
18
18
  end
@@ -10,6 +10,7 @@ module RubyZipkin
10
10
  return 1
11
11
  end
12
12
  end
13
+ #default at .01 Percent
13
14
  return 0.0001
14
15
  end
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module RubyZipkin
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzipkin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Marcin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-12-16 00:00:00 Z
18
+ date: 2013-12-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: scribe