time_bandits 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,8 +92,10 @@ module ActionController #:nodoc:
92
92
  def process_action(event)
93
93
  payload = event.payload
94
94
  additions = ActionController::Base.log_process_action(payload)
95
- Thread.current[:time_bandits_completed_info] =
95
+ Thread.current.thread_variable_set(
96
+ :time_bandits_completed_info,
96
97
  [ event.duration, additions, payload[:view_runtime], "#{payload[:controller]}##{payload[:action]}" ]
98
+ )
97
99
  end
98
100
  end
99
101
 
@@ -12,19 +12,21 @@ module ActiveRecord
12
12
  class LogSubscriber
13
13
 
14
14
  def self.call_count=(value)
15
- Thread.current["active_record_sql_call_count"] = value
15
+ Thread.current.thread_variable_set(:active_record_sql_call_count, value)
16
16
  end
17
17
 
18
18
  def self.call_count
19
- Thread.current["active_record_sql_call_count"] ||= 0
19
+ Thread.current.thread_variable_get(:active_record_sql_call_count) ||
20
+ Thread.current.thread_variable_set(:active_record_sql_call_count, 0)
20
21
  end
21
22
 
22
23
  def self.query_cache_hits=(value)
23
- Thread.current["active_record_sql_query_cache_hits"] = value
24
+ Thread.current.thread_variable_set(:active_record_sql_query_cache_hits, value)
24
25
  end
25
26
 
26
27
  def self.query_cache_hits
27
- Thread.current["active_record_sql_query_cache_hits"] ||= 0
28
+ Thread.current.thread_variable_get(:active_record_sql_query_cache_hits) ||
29
+ Thread.current.thread_variable_set(:active_record_sql_query_cache_hits, 0)
28
30
  end
29
31
 
30
32
  def self.reset_call_count
@@ -18,7 +18,7 @@ module TimeBandits
18
18
  protected
19
19
  def before_dispatch(env, start_time)
20
20
  TimeBandits.reset
21
- Thread.current[:time_bandits_completed_info] = nil
21
+ Thread.current.thread_variable_set(:time_bandits_completed_info, nil)
22
22
 
23
23
  request = ActionDispatch::Request.new(env)
24
24
  path = request.filtered_path
@@ -28,7 +28,7 @@ module TimeBandits
28
28
 
29
29
  def after_dispatch(env, result, run_time)
30
30
  status = result ? result.first : 500
31
- duration, additions, view_time, action = Thread.current[:time_bandits_completed_info]
31
+ duration, additions, view_time, action = Thread.current.thread_variable_get(:time_bandits_completed_info)
32
32
 
33
33
  message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % (run_time*1000)
34
34
  message << " (#{additions.join(' | ')})" unless additions.blank?
@@ -12,11 +12,12 @@ module TimeBandits
12
12
  extend self
13
13
 
14
14
  def info
15
- Thread.current[:time_bandits_database_info] ||= [0.0, 0, 0]
15
+ Thread.current.thread_variable_get(:time_bandits_database_info) ||
16
+ Thread.current.thread_variable_set(:time_bandits_database_info, [0.0, 0, 0])
16
17
  end
17
18
 
18
19
  def info=(info)
19
- Thread.current[:time_bandits_database_info] = info
20
+ Thread.current.thread_variable_set(:time_bandits_database_info, info)
20
21
  end
21
22
 
22
23
  def reset
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/time_bandits.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext'
2
+ require 'thread_variables'
2
3
 
3
4
  module TimeBandits
4
5
 
@@ -49,7 +50,7 @@ module TimeBandits
49
50
  begin
50
51
  result = yield
51
52
  rescue Exception => e
52
- logger.error "Exception: #{e}:\n#{e.backtrace[0..5].join("\n")}"
53
+ logger.error "Exception: #{e.class}(#{e.message}):\n#{e.backtrace[0..5].join("\n")}"
53
54
  end
54
55
  end
55
56
  consumed # needs to be called for DB time consumer
data/time_bandits.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
+ s.add_runtime_dependency("thread_variables")
20
21
  s.add_runtime_dependency("activesupport", [">= 2.3.2"])
21
22
  end
22
23
 
metadata CHANGED
@@ -2,12 +2,12 @@
2
2
  name: time_bandits
3
3
  version: !ruby/object:Gem::Version
4
4
  hash: 19
5
- prerelease: false
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -15,13 +15,26 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-20 00:00:00 +02:00
19
- default_executable:
18
+ date: 2012-11-02 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: activesupport
21
+ name: thread_variables
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: activesupport
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
25
38
  none: false
26
39
  requirements:
27
40
  - - ">="
@@ -33,7 +46,7 @@ dependencies:
33
46
  - 2
34
47
  version: 2.3.2
35
48
  type: :runtime
36
- version_requirements: *id001
49
+ version_requirements: *id002
37
50
  description: Rails Completed Line on Steroids
38
51
  email:
39
52
  - skaes@railsexpress.de
@@ -69,7 +82,6 @@ files:
69
82
  - lib/time_bandits/version.rb
70
83
  - rails/init.rb
71
84
  - time_bandits.gemspec
72
- has_rdoc: true
73
85
  homepage: https://github.com/skaes/time_bandits/
74
86
  licenses: []
75
87
 
@@ -99,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
111
  requirements: []
100
112
 
101
113
  rubyforge_project:
102
- rubygems_version: 1.3.7
114
+ rubygems_version: 1.8.24
103
115
  signing_key:
104
116
  specification_version: 3
105
117
  summary: Custom performance logging for Rails