logjam_agent 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGE1MWZkYjNjYzNjYzQ5MzkyZjQzMGEzMjZmMTBhOTE0YWM5YzdiZQ==
4
+ Yzc0ZDQ5YzMxNjRhMjM3MDE2ZWVkZTIwNDMwYjA0ZDkzYzU3Mjg4OA==
5
5
  data.tar.gz: !binary |-
6
- YjJhZWU1YjdiNjYwYzM4ZDRjNDQ5NzNhY2I3YzE5Njc0NjFhYTBhMg==
6
+ ZmQwOWRiNjIwOGJjZThhYjA4MzM2ODllYTM4M2ZjMTkyYTYzMTg1OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2M2NmJhZDRjZTJlOWM2M2ZjNDg1ZDIxODVkYTIwZmExYTE0MDhjOWIyOGEz
10
- MWM5NmQ1YWQ0YjNjNjE1ZDEyNTM2NjU2ODI0NzY2YTY3NWFiYjA3OTY1ZTVi
11
- MjA2NGNlOTA4MzZhZmNhODQwZjA4MGFiM2NhZjVmMWFjOWUyNzA=
9
+ MjUwNWJkYTIzMDE3OGU0MDRhY2E3N2Q0Njc3MWIwNjAwNjQyMjIxYTQzMjc5
10
+ MzZmN2U5ZTM1MTk2OTkyMGFmMmM0MjM5NzFlMWQ5OGRjNTc0NzU1YjkzYTc3
11
+ MWNmODgzZGJlZTEwZWIyMThhZmQzMjVkMDRiNjFhM2U0MjkzMjA=
12
12
  data.tar.gz: !binary |-
13
- NWRjZGIyZjFlMzg1YmJjYWI5ZWIxYzYwMDU5ZWZjNWQwODdhYzE0YTcxNTZl
14
- MmJlNmJmMWE3Mjg5YmJhZTFhZDE3YjllNjY0NWFkZDJkMjhmMGRkNTAzZDVl
15
- NzZkOWNjNGYzZjVkNzY4ZDUxNGQxYjQzNTM4YmU3M2ZlZTliMWI=
13
+ Y2RjZjZlN2M1ZDZlOGVhZjdkODMwYmU1YjM3YWVmMGRmOGYxNWY2Yjc5Njdk
14
+ MWM0ZTg3ZDc0Y2UzYWY0ODJkM2VmNDJjY2ZiN2RjNzE1MTlmZjAzMWZlYWMy
15
+ ZGZlMDhlMmYwMzYzMmNiODQ2YTg0YWUwNDg2YjZjYTVhOTFmZjM=
data/README.md CHANGED
@@ -46,6 +46,11 @@ module LogjamAgent
46
46
 
47
47
  # Configure cookie obfuscation. Defaults to [/_session\z/].
48
48
  # self.obfuscated_cookies = [/_session\z/]
49
+
50
+ # Configure asset request logging and forwarding. Defaults to ignore
51
+ # asset requests in development mode. Set this to false if you need
52
+ # to debug asset request handling.
53
+ # self.ignore_asset_requests = Rails.env.development?
49
54
  end
50
55
  ```
51
56
 
@@ -8,6 +8,8 @@ module LogjamAgent
8
8
  @app = app
9
9
  @taggers = taggers || Rails.application.config.log_tags || []
10
10
  @hostname = LogjamAgent.hostname
11
+ @asset_prefix = Rails.application.config.assets.prefix rescue "---"
12
+ @ignore_asset_requests = LogjamAgent.ignore_asset_requests
11
13
  end
12
14
 
13
15
  def call(env)
@@ -46,18 +48,27 @@ module LogjamAgent
46
48
  end
47
49
  end
48
50
 
51
+ def ignored_asset_request?(path)
52
+ @ignore_asset_requests && path.starts_with?(@asset_prefix)
53
+ rescue
54
+ false
55
+ end
56
+
49
57
  def before_dispatch(request, env, start_time)
50
58
  TimeBandits.reset
51
59
  Thread.current.thread_variable_set(:time_bandits_completed_info, nil)
52
60
 
53
61
  path = request.filtered_path
54
62
 
55
- logjam_fields = LogjamAgent.request.fields
63
+ logjam_request = LogjamAgent.request
64
+ logjam_request.ignore! if ignored_asset_request?(path)
65
+
66
+ logjam_fields = logjam_request.fields
56
67
  ip = LogjamAgent.ip_obfuscator(request.ip)
57
68
  logjam_fields.merge!(:started_at => start_time.iso8601, :ip => ip, :host => @hostname)
58
69
  logjam_fields.merge!(extract_request_info(request))
59
70
 
60
- info "Started #{request.request_method} \"#{path}\" for #{ip} at #{start_time.to_default_s}"
71
+ info "Started #{request.request_method} \"#{path}\" for #{ip} at #{start_time.to_default_s}" unless logjam_request.ignored?
61
72
  end
62
73
 
63
74
  def after_dispatch(env, result, run_time_ms)
@@ -66,6 +77,7 @@ module LogjamAgent
66
77
  _, additions, view_time, _ = completed_info
67
78
  end
68
79
  request_info = {:total_time => run_time_ms, :code => status, :view_time => view_time || 0.0}
80
+ logjam_request = LogjamAgent.request
69
81
 
70
82
  if (allowed_time_ms = env['HTTP_X_LOGJAM_CALLER_TIMEOUT'].to_i) > 0 && (run_time_ms > allowed_time_ms)
71
83
  warn LogjamAgent::CallerTimeoutExceeded.new("exceeded allowed time by #{(run_time_ms.to_i - allowed_time_ms)} ms")
@@ -73,11 +85,11 @@ module LogjamAgent
73
85
 
74
86
  message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % run_time_ms
75
87
  message << " (#{additions.join(' | ')})" unless additions.blank?
76
- info message
88
+ info message unless logjam_request.ignored?
77
89
 
78
90
  ActiveSupport::LogSubscriber.flush_all!
79
91
 
80
- LogjamAgent.request.fields.merge!(request_info)
92
+ logjam_request.fields.merge!(request_info)
81
93
 
82
94
  env["time_bandits.metrics"] = TimeBandits.metrics
83
95
  end
@@ -54,6 +54,9 @@ module LogjamAgent
54
54
  forwarding_error_logger.formatter = ::Logger::Formatter.new
55
55
  LogjamAgent.forwarding_error_logger = forwarding_error_logger
56
56
 
57
+ # ignore asset requests in development
58
+ LogjamAgent.ignore_asset_requests = Rails.env.development?
59
+
57
60
  # patch controller testing to create a logjam request, because middlewares aren't executed
58
61
  if Rails.env.test?
59
62
  ActiveSupport.on_load(:action_controller) do
@@ -16,6 +16,15 @@ module LogjamAgent
16
16
  @uuid = LogjamAgent.generate_uuid
17
17
  @fields = initial_fields.merge(:request_id => @uuid, :host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines)
18
18
  @mutex = Mutex.new
19
+ @ignored = false
20
+ end
21
+
22
+ def ignore!
23
+ @ignored = true
24
+ end
25
+
26
+ def ignored?
27
+ @ignored
19
28
  end
20
29
 
21
30
  def id
@@ -47,6 +56,7 @@ module LogjamAgent
47
56
  end
48
57
 
49
58
  def forward
59
+ return if @ignored
50
60
  engine = @fields.delete(:engine)
51
61
  # puts @fields.inspect
52
62
  @forwarder.forward(LogjamAgent.encode_payload(@fields), :engine => engine)
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
data/lib/logjam_agent.rb CHANGED
@@ -110,6 +110,9 @@ module LogjamAgent
110
110
  mattr_accessor :exception_matcher
111
111
  self.exception_matcher = nil
112
112
 
113
+ mattr_accessor :ignore_asset_requests
114
+ self.ignore_asset_requests = false
115
+
113
116
  def self.auto_detect_exception(exception_class)
114
117
  # ignore Exception classes created with Class.new (timeout.rb, my old friend)
115
118
  if (class_name = exception_class.to_s) =~ /^[\w:]+$/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement