wildsight 0.1.18 → 0.1.19

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: bfddf497428900da038c5e4ed0c432c6755947d5
4
- data.tar.gz: be828b1ce2c4250e0e18984131baa28cb40cc9d5
3
+ metadata.gz: f9f718b43a5208321225ed5cfcb015b19a66fd79
4
+ data.tar.gz: ec33cba5ffc3a921e27a17d535bb9d5b5c3ebaeb
5
5
  SHA512:
6
- metadata.gz: 1574c438926f0b68e1982a91f23435172c42436f7c775d0c83e77da4bf85bf160900f5785b6bcdc35dd2a22f0edaa40b04bd68281f25f2f88b9c19ffbec01ac9
7
- data.tar.gz: '052695d83931984b4622697a2096d934d067559f13fbed420b89c28eae4f62d69a260ea82ac0cb52af8e7d56242febb6a5782576278fd15ecd86e2272fbdfc38'
6
+ metadata.gz: 14153d97fc2a2068edce6bb26eb193f1acf9afe7f1bc0702085e51271267ca6ad1276d617f20cb1428844e709d8d3f0176e20540ae764f8e63bd4ee60d4f6f4f
7
+ data.tar.gz: a215ffc0e1ad8565eab667554169fc80a7c7ec639b9dfc68d64dca1314b359277e1ac0e5cbb13fdded89b6872a80766d88c1aa4957bb0b4ee6de8cd30c9ee188
@@ -52,7 +52,6 @@ module Wildsight
52
52
  end
53
53
 
54
54
  def submit(event)
55
- event[:client] = 'ruby'
56
55
  @events << event
57
56
  if @events.size > @config['agent']['threshold']
58
57
  self.logger.log(:debug) { 'Uploading collected data' }
@@ -33,12 +33,9 @@ module Wildsight
33
33
  thread.thread_variable_set('wildsight.context', nil)
34
34
  end
35
35
 
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 })
36
+ def report(series, payload = {}, profiler = nil)
37
+ occurred = DateTime.now
38
+ @agent.submit({series: "ruby|#{series}", context: @name, occurred: occurred, payload: payload, profiler: profiler})
42
39
  end
43
40
 
44
41
  def profiler
@@ -19,7 +19,7 @@ module Wildsight
19
19
  :message => msg.to_s.strip
20
20
  }
21
21
  context = @context || Wildsight::Context.detect
22
- context.report(:logs, payload) if context
22
+ context.report(:log, payload) if context
23
23
  return nil
24
24
  end
25
25
 
@@ -9,7 +9,7 @@ module Wildsight
9
9
 
10
10
  def call(env)
11
11
  context = Wildsight::Rack.detect_context(env)
12
- response = context.profiler.duration(:routes) { @app.call(env) }
12
+ response = context.profiler.duration(:rails) { @app.call(env) }
13
13
  return response
14
14
  rescue Exception => e
15
15
  context.report(:exception, extract(e))
@@ -17,7 +17,7 @@ module Wildsight
17
17
  end
18
18
 
19
19
  def extract(exception)
20
- data = {:occurred => DateTime.now, :message => exception.message, :name => exception.class.name, :backtrace => exception.backtrace}
20
+ data = {:message => exception.message, :name => exception.class.name, :backtrace => exception.backtrace}
21
21
  data[:cause] = extract_exception(exception.cause) if exception.cause
22
22
  return data
23
23
  end
@@ -3,7 +3,7 @@ module Wildsight
3
3
 
4
4
  class TopMiddleware
5
5
 
6
- METRICS = [:middleware, :routes]
6
+ METRICS = [:middleware, :rails, :view, :database]
7
7
 
8
8
  REQUEST_INCLUDE_KEYS = ['SCRIPT_NAME', 'QUERY_STRING', 'PATH_INFO', 'REMOTE_ADDR']
9
9
  REQUEST_EXCLUDE_KEYS = ['HTTP_COOKIE']
@@ -18,39 +18,41 @@ module Wildsight
18
18
  context.bind_thread
19
19
 
20
20
  context.data[:rack] ||= {
21
- request_target: env['SCRIPT_NAME'].to_s + env['PATH_INFO'].to_s,
22
- request_headers: {}
21
+ request: {
22
+ target: env['SCRIPT_NAME'].to_s + env['PATH_INFO'].to_s,
23
+ headers: {}
24
+ },
25
+ response: {
26
+ }
23
27
  }
24
28
 
25
29
  env.each_pair do |key,value|
26
30
  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
+ context.data[:rack][:request][:headers][key] = value if REQUEST_INCLUDE_KEYS.include?(name)
32
+ context.data[:rack][:request][:headers][key] = value if name.start_with?('HTTP_')
33
+ context.data[:rack][:request][:headers][key] = value if name.start_with?('REQUEST_')
34
+ context.data[:rack][:request][:headers][key] = value if name.start_with?('SERVER_')
31
35
  end
32
36
 
33
37
  env[Wildsight::Rack::RACK_ENV_KEY] = context
34
38
 
35
39
  response = context.profiler.duration(:middleware) { @app.call(env) }
36
40
 
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
41
+ if !context.data[:session] && !env['rack.session'].nil? && env['rack.session'].respond_to?(:id)
42
+ context.data[:session] ||= {id: env['rack.session'].id}
39
43
  end
40
44
 
41
- REQUEST_EXCLUDE_KEYS.each { |key| context.data[:rack][:request_headers].delete(key) }
45
+ REQUEST_EXCLUDE_KEYS.each { |key| context.data[:rack][:request][:headers].delete(key) }
42
46
 
43
47
  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) }
48
+ context.data[:rack][:response][:code] ||= response[0]
49
+ context.data[:rack][:response][:headers] ||= response[1].dup
50
+ RESPONSE_EXCLUDE_KEYS.each { |key| context.data[:rack][:response][:headers].delete(key) }
47
51
  end
48
52
 
49
- context.data[:rack] = {
50
- metrics: METRICS.inject({}) { |c, name| c[name] = context.profiler.data[name]; c }
51
- }.merge(context.data[:rack])
53
+ profiler = METRICS.inject({}) { |c, name| c[name] = context.profiler.data[name]; c }
52
54
 
53
- context.report(:action_controller, context.data[:rack])
55
+ context.report(:action_controller, context.data[:rack], profiler)
54
56
 
55
57
  return response
56
58
  ensure
@@ -10,19 +10,8 @@ module Wildsight
10
10
 
11
11
  include Wildsight::Rails::ActionController
12
12
 
13
- alias_method :process_without_ws, :process
14
13
  alias_method :process_action_without_ws, :process_action
15
14
 
16
- def process(*args)
17
- context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
18
- if context
19
- result = context.profiler.duration(:rails) { process_without_ws(*args) }
20
- else
21
- result = process_without_ws(*args)
22
- end
23
- return result
24
- end
25
-
26
15
  def wildsight_context
27
16
  @_wildsight_context ||= Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {})
28
17
  end
@@ -32,19 +21,17 @@ module Wildsight
32
21
  return process_action_without_ws(*args) unless context
33
22
 
34
23
  if respond_to?(:request)
35
- context.data[:rack][:request_target] = self.class.name + '#' + request.params['action']
24
+ context.data[:rack][:request][:target] = self.class.name + '#' + request.params['action']
36
25
 
37
- context.data[:rack][:method] = request.method
38
- context.data[:rack][:path] = request.original_fullpath
39
- context.data[:rack][:params] = request.filtered_parameters
26
+ context.data[:rack][:request][:method] = request.method
27
+ context.data[:rack][:request][:path] = request.original_fullpath
28
+ context.data[:rack][:request][:params] = request.filtered_parameters
40
29
 
41
- context.data[:rack][:session_id] = request.session.id
30
+ context.data[:rack][:request][:session] = {id: request.session.id}
42
31
 
43
- context.data[:rack][:url] = request.original_url
44
- context.data[:rack][:protocol] = request.protocol
45
- context.data[:rack][:host] = request.host_with_port
32
+ context.data[:rack][:request][:url] = request.original_url
46
33
 
47
- context.data[:rack][:remote_ip] = request.remote_ip
34
+ context.data[:rack][:request][:remote] = request.remote_ip
48
35
  end
49
36
  result = context.profiler.duration(:action) { process_action_without_ws(*args) }
50
37
  return result
@@ -108,10 +95,8 @@ module Wildsight
108
95
 
109
96
  event = {
110
97
  :name => args[4][:name],
111
- :statement => args[4][:statement_name],
112
98
  :query => args[4][:sql],
113
- :connection => args[4][:connection_id],
114
- :occurred => args[1],
99
+ :connection => args[4][:connection_id].to_s,
115
100
  :duration => (args[2] - args[1]) * 1000
116
101
  }
117
102
  context.report(:active_record, event)
@@ -1,3 +1,3 @@
1
1
  module Wildsight
2
- VERSION = '0.1.18'
2
+ VERSION = '0.1.19'
3
3
  end
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.18
4
+ version: 0.1.19
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-07-21 00:00:00.000000000 Z
12
+ date: 2016-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json