wildsight 0.1.16 → 0.1.17

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: 6851f06ff1db60ac0d56474afda00fd6b18e09d1
4
- data.tar.gz: 3312120ae18f8fd3b5a4afe0914818b20086e8a5
3
+ metadata.gz: f4791f160bb8740c344c10ceb3d07444b222911e
4
+ data.tar.gz: f55122ba5015cc584c5421b1e973a107dfccc335
5
5
  SHA512:
6
- metadata.gz: bb319c3e5a8f5cfe08e3e94e0ba276350e4662ce39569d898cbf235650c429ec66a6d1e244c20e641fb368015951c3bf937c5c6f49ca883f17c1089dc4e46b92
7
- data.tar.gz: 58b6abffe9a936605b7880f892293819b20b42f71b56afe39fe68e00a50b1883fb9e928e454748eb0d77674f909ab7e126387354f17e4a8b1ea12a532072ba38
6
+ metadata.gz: 62b76b5ef370d73ff68f5b735b9dc290a8c17158023b1f71d02674e848a1fe908d5d171359bf21370b2b73afac06be073fdf95a7315a1a9e7a0405c6499ab611
7
+ data.tar.gz: f3a334daba22fe22d1900c52f68fad99500e33db8577b10e10a2779edf56110ec9a8bc958601bb7148836efcfbe879ffe510f16eabeca11731d60e143f8638cf
@@ -52,6 +52,7 @@ module Wildsight
52
52
  end
53
53
 
54
54
  def submit(event)
55
+ event[:client] = 'ruby'
55
56
  @events << event
56
57
  if @events.size > @config['agent']['threshold']
57
58
  self.logger.log(:debug) { 'Uploading collected data' }
@@ -1,9 +1,3 @@
1
- require 'wildsight/context/rack'
2
- require 'wildsight/context/rails'
3
- require 'wildsight/context/logger'
4
- require 'wildsight/context/exception'
5
- require 'wildsight/context/active_record'
6
-
7
1
  module Wildsight
8
2
  module Context
9
3
 
@@ -13,22 +7,18 @@ module Wildsight
13
7
 
14
8
  class Context
15
9
 
16
- include Wildsight::Context::Logs
17
- include Wildsight::Context::Exception
18
- include Wildsight::Context::Rack
19
- include Wildsight::Context::Rails
20
- include Wildsight::Context::ActiveRecord
21
-
22
- attr_reader :name
23
-
24
10
  def initialize(name, agent)
25
11
  @name = name
26
12
  @agent = agent
27
13
  @data = {}
28
14
  end
29
15
 
30
- def submit
31
- @agent.submit({ :context => { :id => @name }, :payload => @data })
16
+ def name
17
+ @name
18
+ end
19
+
20
+ def data
21
+ @data
32
22
  end
33
23
 
34
24
  def unregister
@@ -43,8 +33,12 @@ module Wildsight
43
33
  thread.thread_variable_set('wildsight.context', nil)
44
34
  end
45
35
 
46
- def data
47
- @data
36
+ def report(series, occurred = DateTime.now, payload = {})
37
+ if occurred.kind_of?(Hash)
38
+ payload = occurred
39
+ occurred = DateTime.now
40
+ end
41
+ @agent.submit({ series: series, context: @name, occurred: occurred, payload: payload })
48
42
  end
49
43
 
50
44
  def profiler
@@ -3,18 +3,6 @@ require 'logger'
3
3
  module Wildsight
4
4
  module Context
5
5
 
6
- module Logs
7
-
8
- def log_data
9
- @data[:logs] = []
10
- end
11
-
12
- def log_report(log)
13
- log_data << log
14
- end
15
-
16
- end
17
-
18
6
  class Logger < ::Logger
19
7
 
20
8
  def initialize(context = nil)
@@ -30,9 +18,8 @@ module Wildsight
30
18
  :facility => progname,
31
19
  :message => msg.to_s.strip
32
20
  }
33
- context = @context
34
- context = Wildsight::Context.detect unless context
35
- context.log_report(payload)
21
+ context = @context || Wildsight::Context.detect
22
+ context.report(:logs, payload) if context
36
23
  return nil
37
24
  end
38
25
 
@@ -4,30 +4,92 @@ module Wildsight
4
4
 
5
5
  def initialize(context)
6
6
  @context = context
7
- @context.data[:profiler] ||= {}
7
+ @data = {}
8
+ @profile = nil
8
9
  end
9
10
 
10
11
  def duration(name, time = nil, options = {}, &block)
12
+ p = @profile = Profile.new(@profile)
13
+
11
14
  if block_given?
12
- start = DateTime.now.to_f
13
- result = block.call
14
- stop = DateTime.now.to_f
15
- item = { before: start, after: stop }
15
+ @profile.profile!(&block)
16
16
  else
17
- result = nil
18
- item = { before: time[0], after: time[1] }
17
+ @profile.set(time[0], time[1])
19
18
  end
20
- item[:duration] = (item[:after] - item[:before]) * 1000
21
- durations[name] ||= { intervals: [], duration: 0.0 }
22
- durations[name][:intervals] << item
23
- durations[name][:duration] += item[:duration]
24
- return result
19
+
20
+ @profile = @profile.close
21
+
22
+ durations(name)[:intervals] << p.export
23
+ durations(name)[:duration] += p.duration
24
+
25
+ raise p.exception if p.exception
26
+ return p.result
25
27
  end
26
28
 
27
- def durations
28
- @context.data[:profiler][:durations] ||= {}
29
+ def data
30
+ @data
31
+ end
32
+
33
+ def durations(name)
34
+ @data[name] ||= { intervals: [], duration: 0.0 }
29
35
  end
30
36
 
31
37
  end
38
+
39
+ class Profile
40
+
41
+ def initialize(parent)
42
+ @parent = parent
43
+ @subtimes = []
44
+ @result = nil
45
+ @exception = nil
46
+ end
47
+
48
+ def set(before, after)
49
+ @before = before
50
+ @after = after
51
+ end
52
+
53
+ def profile!(&block)
54
+ @before = DateTime.now.to_f
55
+ begin
56
+ @result = block.call
57
+ rescue Exception => e
58
+ @exception = e
59
+ end
60
+ @after = DateTime.now.to_f
61
+ end
62
+
63
+ def close
64
+ @parent << duration if @parent
65
+ @parent
66
+ end
67
+
68
+ def result
69
+ @result
70
+ end
71
+
72
+ def exception
73
+ @exception
74
+ end
75
+
76
+ def <<(time)
77
+ @subtimes << time
78
+ end
79
+
80
+ def duration
81
+ return raw - @subtimes.inject(0.0) { |c,x| c + x }
82
+ end
83
+
84
+ def raw
85
+ (@after - @before) * 1000
86
+ end
87
+
88
+ def export
89
+ { before: @before, after: @after, duration: duration, raw: raw }
90
+ end
91
+
92
+ end
93
+
32
94
  end
33
95
  end
@@ -0,0 +1,28 @@
1
+ module Wildsight
2
+ module Rack
3
+
4
+ class BottomMiddleware
5
+
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ context = Wildsight::Rack.detect_context(env)
12
+ response = context.profiler.duration(:routes) { @app.call(env) }
13
+ return response
14
+ rescue Exception => e
15
+ context.report(:exception, extract(e))
16
+ raise e
17
+ end
18
+
19
+ def extract(exception)
20
+ data = {:occurred => DateTime.now, :message => exception.message, :name => exception.class.name, :backtrace => exception.backtrace}
21
+ data[:cause] = extract_exception(exception.cause) if exception.cause
22
+ return data
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ module Wildsight
2
+ module Rack
3
+
4
+ RACK_ENV_KEY = 'wildsight.context'
5
+
6
+ def self.detect_context(env)
7
+ env[Wildsight::Rack::RACK_ENV_KEY] || Wildsight::Context.detect
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ module Wildsight
2
+ module Rack
3
+
4
+ class TopMiddleware
5
+
6
+ METRICS = [:middleware, :routes]
7
+
8
+ REQUEST_INCLUDE_KEYS = ['SCRIPT_NAME', 'QUERY_STRING', 'PATH_INFO', 'REMOTE_ADDR']
9
+ REQUEST_EXCLUDE_KEYS = ['HTTP_COOKIE']
10
+ RESPONSE_EXCLUDE_KEYS = ['Set-Cookie']
11
+
12
+ def initialize(app)
13
+ @app = app
14
+ end
15
+
16
+ def call(env)
17
+ context = Wildsight::Agent.default.context
18
+ context.bind_thread
19
+
20
+ context.data[:rack] ||= {
21
+ request_target: env['SCRIPT_NAME'].to_s + env['PATH_INFO'].to_s,
22
+ request_headers: {}
23
+ }
24
+
25
+ env.each_pair do |key,value|
26
+ name = key.to_s
27
+ context.data[:rack][:request_headers][key] = value if REQUEST_INCLUDE_KEYS.include?(name)
28
+ context.data[:rack][:request_headers][key] = value if name.start_with?('HTTP_')
29
+ context.data[:rack][:request_headers][key] = value if name.start_with?('REQUEST_')
30
+ context.data[:rack][:request_headers][key] = value if name.start_with?('SERVER_')
31
+ end
32
+
33
+ env[Wildsight::Rack::RACK_ENV_KEY] = context
34
+
35
+ response = context.profiler.duration(:middleware) { @app.call(env) }
36
+
37
+ if !context.data[:session_id] && !env['rack.session'].nil? && env['rack.session'].respond_to?(:id)
38
+ context.data[:session_id] ||= env['rack.session'].id
39
+ end
40
+
41
+ REQUEST_EXCLUDE_KEYS.each { |key| context.data[:rack][:request_headers].delete(key) }
42
+
43
+ if response
44
+ context.data[:rack][:response_code] ||= response[0]
45
+ context.data[:rack][:response_headers] ||= response[1].dup
46
+ RESPONSE_EXCLUDE_KEYS.each { |key| context.data[:rack][:response_headers].delete(key) }
47
+ end
48
+
49
+ context.data[:rack] = {
50
+ metrics: METRICS.inject({}) { |c, name| c[name] = context.profiler.data[name]; c }
51
+ }.merge(context.data[:rack])
52
+
53
+ context.report(:action_controller, context.data[:rack])
54
+
55
+ return response
56
+ ensure
57
+ env.delete(Wildsight::Rack::RACK_ENV_KEY)
58
+ context.release_thread
59
+ context.unregister
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
@@ -1,7 +1,6 @@
1
1
  module Wildsight
2
2
  module Rails
3
3
  module ActiveRecord
4
-
5
4
  end
6
5
  end
7
6
  end
@@ -6,37 +6,6 @@ module Wildsight
6
6
 
7
7
  @instrumented = true
8
8
 
9
- ::Rails::Engine.class_eval do
10
-
11
- alias_method :call_without_ws, :call
12
-
13
- def call(env)
14
- context = Wildsight::Agent.default.context
15
- context.bind_thread
16
- context.rack_instrument_request(env)
17
-
18
- response = context.profiler.duration(:middleware) { call_without_ws(env) }
19
-
20
- return response
21
- ensure
22
- context.rack_report(env, response)
23
- context.release_thread
24
- context.unregister
25
- end
26
-
27
- end
28
-
29
- ::ActionDispatch::Routing::RouteSet.class_eval do
30
-
31
- alias_method :call_without_ws, :call
32
-
33
- def call(env)
34
- context = Wildsight::Context::Rack.detect_context(env)
35
- result = context.profiler.duration(:routing) { call_without_ws(env) }
36
- return result
37
- end
38
- end
39
-
40
9
  ::AbstractController::Base.class_eval do
41
10
 
42
11
  include Wildsight::Rails::ActionController
@@ -45,7 +14,7 @@ module Wildsight
45
14
  alias_method :process_action_without_ws, :process_action
46
15
 
47
16
  def process(*args)
48
- context = Wildsight::Context::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
17
+ context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
49
18
  if context
50
19
  result = context.profiler.duration(:rails) { process_without_ws(*args) }
51
20
  else
@@ -55,16 +24,31 @@ module Wildsight
55
24
  end
56
25
 
57
26
  def wildsight_context
58
- @_wildsight_context ||= Wildsight::Context::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
27
+ @_wildsight_context ||= Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
59
28
  end
60
29
 
61
30
  def process_action(*args)
62
- context = Wildsight::Context::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
63
- context.rails_extract(self)
31
+ context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
32
+ return process_action_without_ws(*args) unless context
33
+
34
+ if respond_to?(:request)
35
+ context.data[:rack][:request_target] = self.class.name + '#' + request.params['action']
36
+
37
+ context.data[:rack][:method] = request.method
38
+ context.data[:rack][:path] = request.original_fullpath
39
+ context.data[:rack][:params] = request.filtered_parameters
40
+
41
+ context.data[:rack][:session_id] = request.session.id
42
+
43
+ context.data[:rack][:url] = request.original_url
44
+ context.data[:rack][:protocol] = request.protocol
45
+ context.data[:rack][:host] = request.host_with_port
46
+
47
+ context.data[:rack][:remote_ip] = request.remote_ip
48
+ end
64
49
  result = context.profiler.duration(:action) { process_action_without_ws(*args) }
65
50
  return result
66
51
  rescue Exception => e
67
- request.env['rack.exception'] = e
68
52
  raise e
69
53
  end
70
54
 
@@ -75,8 +59,8 @@ module Wildsight
75
59
  alias_method :render_without_ws, :render
76
60
 
77
61
  def render(*args, &block)
78
- context = Wildsight::Context::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
79
- result = context.profiler.duration(:render) { render_without_ws(*args, &block) }
62
+ context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
63
+ result = context.profiler.duration(:view) { render_without_ws(*args, &block) }
80
64
  return result
81
65
  end
82
66
 
@@ -86,6 +70,14 @@ module Wildsight
86
70
 
87
71
  class Railtie < ::Rails::Railtie
88
72
 
73
+ initializer('wildsight.rails.middleware.top') do |app|
74
+ app.middleware.unshift(Wildsight::Rack::TopMiddleware)
75
+ end
76
+
77
+ initializer('wildsight.rails.middleware.bottom') do |app|
78
+ app.middleware.use(Wildsight::Rack::BottomMiddleware)
79
+ end
80
+
89
81
  initializer('wildsight.rails.logger') do |app|
90
82
  ::Rails.logger.extend(ActiveSupport::Logger.broadcast(Wildsight::Context::Logger.new))
91
83
  end
@@ -99,7 +91,6 @@ module Wildsight
99
91
 
100
92
  initializer('wildsight.action_controller.metrics') do |app|
101
93
  ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
102
-
103
94
  end
104
95
  end
105
96
 
@@ -124,7 +115,7 @@ module Wildsight
124
115
  :occurred => args[1],
125
116
  :duration => (args[2] - args[1]) * 1000
126
117
  }
127
- context.active_record_report(event)
118
+ context.report(:active_record, event)
128
119
  end
129
120
  end
130
121
 
@@ -7,6 +7,7 @@ module Wildsight
7
7
  @agent = agent
8
8
  @config = config
9
9
  @connection = Faraday.new(:url => @config['transport']['url']) do |faraday|
10
+ faraday.request(:multipart)
10
11
  faraday.request(:url_encoded)
11
12
  faraday.adapter(Faraday.default_adapter)
12
13
  end
@@ -15,8 +16,7 @@ module Wildsight
15
16
 
16
17
  def send(payload)
17
18
  begin
18
- data = { payload: MultiJson.dump(payload), client: 'ruby' }
19
- @agent.logger.log(:debug) { @connection.post(@uri, data).inspect }
19
+ @agent.logger.log(:debug) { @connection.post(@uri, payload: MultiJson.dump(payload)).inspect }
20
20
  rescue Exception => e
21
21
  @agent.logger.log(:error) { e }
22
22
  end
@@ -13,8 +13,7 @@ module Wildsight
13
13
 
14
14
  def send(payload)
15
15
  begin
16
- data = { payload: MultiJson.dump(payload), client: 'ruby' }
17
- @agent.logger.log(:debug) { Net::HTTP.post_form(@uri, data).inspect }
16
+ @agent.logger.log(:debug) { Net::HTTP.post_form(@uri, payload: MultiJson.dump(payload)).inspect }
18
17
  rescue Exception => e
19
18
  @agent.logger.log(:error) { e }
20
19
  end
@@ -1,3 +1,3 @@
1
1
  module Wildsight
2
- VERSION = '0.1.16'
2
+ VERSION = '0.1.17'
3
3
  end
@@ -4,11 +4,13 @@ require 'wildsight/transport/transport'
4
4
  require 'wildsight/metrics/metrics'
5
5
  require 'wildsight/profiler/profiler'
6
6
  require 'wildsight/context/context'
7
+ require 'wildsight/context/logger'
7
8
  require 'wildsight/agent/agent'
8
9
 
9
10
  if defined?(Rack)
10
- require 'wildsight/rack/middleware_context'
11
- require 'wildsight/rack/middleware'
11
+ require 'wildsight/rack/rack'
12
+ require 'wildsight/rack/top_middleware'
13
+ require 'wildsight/rack/bottom_middleware'
12
14
  end
13
15
 
14
16
  if defined?(Rails)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wildsight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Jelen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-06-25 00:00:00.000000000 Z
12
+ date: 2016-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -103,19 +103,16 @@ files:
103
103
  - lib/wildsight/agent/config.yml
104
104
  - lib/wildsight/agent/logger.rb
105
105
  - lib/wildsight/agent/tools.rb
106
- - lib/wildsight/context/active_record.rb
107
106
  - lib/wildsight/context/context.rb
108
- - lib/wildsight/context/exception.rb
109
107
  - lib/wildsight/context/logger.rb
110
- - lib/wildsight/context/rack.rb
111
- - lib/wildsight/context/rails.rb
112
108
  - lib/wildsight/metrics/counter.rb
113
109
  - lib/wildsight/metrics/gauge.rb
114
110
  - lib/wildsight/metrics/metrics.rb
115
111
  - lib/wildsight/metrics/statistics.rb
116
112
  - lib/wildsight/profiler/profiler.rb
117
- - lib/wildsight/rack/middleware.rb
118
- - lib/wildsight/rack/middleware_context.rb
113
+ - lib/wildsight/rack/bottom_middleware.rb
114
+ - lib/wildsight/rack/rack.rb
115
+ - lib/wildsight/rack/top_middleware.rb
119
116
  - lib/wildsight/rails/action_controller.rb
120
117
  - lib/wildsight/rails/active_record.rb
121
118
  - lib/wildsight/rails/railtie.rb
@@ -1,17 +0,0 @@
1
- module Wildsight
2
- module Context
3
-
4
- module ActiveRecord
5
-
6
- def active_record_data
7
- @data[:active_record] ||= []
8
- end
9
-
10
- def active_record_report(event)
11
- active_record_data << event
12
- end
13
-
14
- end
15
-
16
- end
17
- end
@@ -1,24 +0,0 @@
1
- module Wildsight
2
- module Context
3
-
4
- module Exception
5
-
6
- def exception_data
7
- @data[:exceptions] = []
8
- end
9
-
10
- def exception_report(exception)
11
- exception_data << exception_extract(exception)
12
- end
13
-
14
-
15
- def exception_extract(exception)
16
- data = {:occurred => DateTime.now, :message => exception.message, :name => exception.class.name, :backtrace => exception.backtrace}
17
- data[:cause] = extract_exception(exception.cause) if exception.cause
18
- return data
19
- end
20
-
21
- end
22
-
23
- end
24
- end
@@ -1,64 +0,0 @@
1
- module Wildsight
2
- module Context
3
-
4
- module Rack
5
-
6
- RACK_ENV_KEY = 'wildsight.context'
7
-
8
- REQUEST_INCLUDE_KEYS = ['SCRIPT_NAME', 'QUERY_STRING', 'PATH_INFO', 'REMOTE_ADDR']
9
- REQUEST_EXCLUDE_KEYS = ['HTTP_COOKIE']
10
- RESPONSE_EXCLUDE_KEYS = ['Set-Cookie']
11
-
12
- def self.detect_context(env)
13
- env[RACK_ENV_KEY] || Wildsight::Context.detect
14
- end
15
-
16
- def rack_instrument_request(env)
17
- env[RACK_ENV_KEY] = self
18
- end
19
-
20
- def rack_data
21
- @data[:rack] ||= {}
22
- end
23
-
24
- def rack_report(env, response = nil)
25
- env.delete(RACK_ENV_KEY)
26
-
27
- rack_data[:request_target] ||= env['SCRIPT_NAME'].to_s + env['PATH_INFO'].to_s
28
-
29
- env.each_pair do |key,value|
30
- name = key.to_s
31
- rack_data[:request_headers] ||= {}
32
- rack_data[:request_headers][key] = value if REQUEST_INCLUDE_KEYS.include?(name)
33
- rack_data[:request_headers][key] = value if name.start_with?('HTTP_')
34
- rack_data[:request_headers][key] = value if name.start_with?('REQUEST_')
35
- rack_data[:request_headers][key] = value if name.start_with?('SERVER_')
36
- end
37
-
38
- if !rack_data[:session_id] && !env['rack.session'].nil? && env['rack.session'].respond_to?(:id)
39
- rack_data[:session_id] ||= env['rack.session'].id
40
- end
41
-
42
- REQUEST_EXCLUDE_KEYS.each { |key| rack_data[:request_headers].delete(key) }
43
-
44
- if response
45
- rack_data[:response_code] ||= response[0]
46
- rack_data[:response_headers] ||= response[1].dup
47
- RESPONSE_EXCLUDE_KEYS.each { |key| rack_data[:response_headers].delete(key) }
48
- end
49
-
50
- exception = env['rack.exception'] || env['action_dispatch.exception'] || env['sinatra.error']
51
-
52
- if exception
53
- exception_report(exception)
54
- end
55
-
56
- self.submit
57
- rescue => e
58
- @agent.logger.log(:error, e)
59
- end
60
-
61
- end
62
-
63
- end
64
- end
@@ -1,33 +0,0 @@
1
- module Wildsight
2
- module Context
3
-
4
- module Rails
5
-
6
- def rails_data
7
- @data[:rails] ||= {}
8
- end
9
-
10
- def rails_extract(controller)
11
- if respond_to?(:request)
12
- request = controller.request
13
-
14
- rack_data[:request_target] = controller.class.name + '#' + request.params['action']
15
-
16
- rack_data[:method] = request.method
17
- rack_data[:path] = request.original_fullpath
18
- rack_data[:params] = request.filtered_parameters
19
-
20
- rack_data[:session_id] = request.session.id
21
-
22
- rack_data[:url] = request.original_url
23
- rack_data[:protocol] = request.protocol
24
- rack_data[:host] = request.host_with_port
25
-
26
- rack_data[:remote_ip] = request.remote_ip
27
- end
28
- end
29
-
30
- end
31
-
32
- end
33
- end
@@ -1,17 +0,0 @@
1
- module Wildsight
2
- module Rack
3
-
4
- class Middleware
5
-
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- MiddlewareContext.new(@app).call(env)
12
- end
13
-
14
- end
15
-
16
- end
17
- end
@@ -1,26 +0,0 @@
1
- module Wildsight
2
- module Rack
3
-
4
- class MiddlewareContext
5
-
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- @context = Wildsight::Agent.default.context
12
- @context.bind_thread
13
- @context.rack_instrument_request(env)
14
- response = @app.call(env)
15
- rescue Exception => exception
16
- env['rack.exception'] = exception
17
- raise exception
18
- ensure
19
- @context.rack_report(env, response)
20
- @context.release_thread
21
- @context.unregister
22
- end
23
-
24
- end
25
- end
26
- end