wildsight 0.1.18 → 0.1.19
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.
- checksums.yaml +4 -4
 - data/lib/wildsight/agent/agent.rb +0 -1
 - data/lib/wildsight/context/context.rb +3 -6
 - data/lib/wildsight/context/logger.rb +1 -1
 - data/lib/wildsight/rack/bottom_middleware.rb +2 -2
 - data/lib/wildsight/rack/top_middleware.rb +19 -17
 - data/lib/wildsight/rails/railtie.rb +8 -23
 - data/lib/wildsight/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f9f718b43a5208321225ed5cfcb015b19a66fd79
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ec33cba5ffc3a921e27a17d535bb9d5b5c3ebaeb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 14153d97fc2a2068edce6bb26eb193f1acf9afe7f1bc0702085e51271267ca6ad1276d617f20cb1428844e709d8d3f0176e20540ae764f8e63bd4ee60d4f6f4f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a215ffc0e1ad8565eab667554169fc80a7c7ec639b9dfc68d64dca1314b359277e1ac0e5cbb13fdded89b6872a80766d88c1aa4957bb0b4ee6de8cd30c9ee188
         
     | 
| 
         @@ -33,12 +33,9 @@ module Wildsight 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    thread.thread_variable_set('wildsight.context', nil)
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  def report(series,  
     | 
| 
       37 
     | 
    
         
            -
                     
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       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
         
     | 
| 
         @@ -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(: 
     | 
| 
      
 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 = {: 
     | 
| 
      
 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, : 
     | 
| 
      
 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 
     | 
    
         
            -
                         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 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][: 
     | 
| 
       28 
     | 
    
         
            -
                      context.data[:rack][: 
     | 
| 
       29 
     | 
    
         
            -
                      context.data[:rack][: 
     | 
| 
       30 
     | 
    
         
            -
                      context.data[:rack][: 
     | 
| 
      
 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[: 
     | 
| 
       38 
     | 
    
         
            -
                      context.data[: 
     | 
| 
      
 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][: 
     | 
| 
      
 45 
     | 
    
         
            +
                    REQUEST_EXCLUDE_KEYS.each { |key| context.data[:rack][:request][:headers].delete(key) }
         
     | 
| 
       42 
46 
     | 
    
         | 
| 
       43 
47 
     | 
    
         
             
                    if response
         
     | 
| 
       44 
     | 
    
         
            -
                      context.data[:rack][: 
     | 
| 
       45 
     | 
    
         
            -
                      context.data[:rack][: 
     | 
| 
       46 
     | 
    
         
            -
                      RESPONSE_EXCLUDE_KEYS.each { |key| context.data[:rack][: 
     | 
| 
      
 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[ 
     | 
| 
       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][: 
     | 
| 
      
 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][: 
     | 
| 
      
 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][: 
     | 
| 
      
 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)
         
     | 
    
        data/lib/wildsight/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2016-07-22 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: multi_json
         
     |