active-record-profiler 1.0 → 1.1.0

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: 211f71211f9004c489a7de54d5c5e59698d7597d
4
- data.tar.gz: 956d9fbd435a5eaa6159e221fa4a7182532e6a70
3
+ metadata.gz: 1a7100d5c7531cd91b863eda7d33b18e4bf42f70
4
+ data.tar.gz: bff2d8ace930dbc38ce3a1ec2bc6a36ed9f6e33a
5
5
  SHA512:
6
- metadata.gz: a7b4b502cbd6e098f23aa3666b1567954aedf24d4de83e69168a404216e914ed53c011a815b85ca8bcf5febe33bddf08330969631f28cc87a9f5474a119f3df5
7
- data.tar.gz: a8e5101c041a79d1383039ac2ab661d832b3a6d054d19be37a3255f5d8eae71b3ce1af69f3445f64ced0dc667248751d0ff108f5c86f987227025e0e8bd906e3
6
+ metadata.gz: 983b8595fbeedc12c65082590033ff996adc409c044682cd8cb6ece0dc893353771c72fdb1b063d137a4f840cceb582f7a9cffafb41a15cd6f7ddbaa78320501
7
+ data.tar.gz: 4463447815648e31ca7ac8ace162fa9bcb22647510af5827e7867f3f8a9534c8fe829553ba6e483665d22f53005f12b4674922a7c60937d99350443b6abcf827
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
+ # 1.1.0
2
+
3
+ * Add self-profiling for the logger component
4
+ * Prevent calling a logger.add block twice in the unusual case where the block returns a nil message.
5
+ * Convert duration in events from milliseconds to seconds (doh!). You'll want to clear old profiler data when upgrading.
6
+ * Don't accumulate statistics for queries fulfilled by the CACHE
7
+
8
+ # 1.0
9
+
10
+ * Converted to Rails Engine, with mountable web interface
11
+ * Simplified configuration somewhat
12
+
1
13
  # 0.1.0
2
14
 
3
15
  * Convert from plugin to gem
4
-
5
- TODO: Convert to an engine for the reports
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ActiveRecordProfiler
2
2
  ====================
3
+ ** Note: ** This gem is in transition from an old Rails 2.x plugin and still has some issues to iron out. In particular, using the notification system to track ActiveRecord query durations isn't as straightforward as it seems, so the times recorded by the profiler don't match the times ActiveRecord reports in the logs. It's still handy for tracking where your N+1 queries are coming from, thoug....
3
4
 
4
5
  The `active-record-profiler` gem adds a log formatter to improve the standard SQL logging and a log subscriber to provide profiler-like tracking of SQL statements generated by application code. The log formatter makes the SQL statements in your logs look like this (imagine it's all in one log line):
5
6
 
@@ -2,11 +2,14 @@ require 'active_record/log_subscriber'
2
2
 
3
3
  module ActiveRecordProfiler
4
4
  class LogSubscriber < ActiveRecord::LogSubscriber
5
+ CACHE_PAYLOAD_NAME = 'CACHE'
6
+
5
7
  def sql(event)
6
8
  start_time = Time.now.to_f
7
9
  payload = event.payload
10
+ return if payload[:name] == CACHE_PAYLOAD_NAME
8
11
 
9
- duration = event.duration
12
+ duration = event.duration / 1000.0 # convert from ms to seconds
10
13
  sql_string = payload[:sql]
11
14
 
12
15
  begin
@@ -5,10 +5,13 @@ module ActiveRecordProfiler
5
5
 
6
6
  def add(severity, message = nil, progname = nil, &block)
7
7
  return true if (severity || ::Logger::Severity::UNKNOWN) < self.level
8
+ start_time = Time.now.to_f
8
9
 
10
+ called_block = false
9
11
  if message.nil?
10
12
  if block_given?
11
13
  message = yield
14
+ called_block = true
12
15
  else
13
16
  message = progname
14
17
  progname = self.progname
@@ -16,8 +19,18 @@ module ActiveRecordProfiler
16
19
  end
17
20
 
18
21
  message = add_call_site_to_message(message)
22
+ collector.record_self_info((Time.now.to_f - start_time), 'enhancing log line') if ActiveRecordProfiler::Collector.profile_self?
19
23
 
20
- super(severity, message, progname, &block)
24
+ # We don't use super() here to pass control to the delegate because if we
25
+ # do, there's no way to prevent super() from seeing the block and yielding
26
+ # to it, and if we've already yielded to the block, this could result in a
27
+ # double yield (if the message is nil after calling the block).
28
+ if called_block
29
+ # don't pass the block, since we already called it
30
+ __getobj__.add(severity, message, progname)
31
+ else
32
+ __getobj__.add(severity, message, progname, &block)
33
+ end
21
34
  end
22
35
 
23
36
  # Define all of the basic logging methods so that they invoke our add()
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordProfiler
2
- VERSION = "1.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-record-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-24 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
+ - ".ruby-version"
107
108
  - CHANGELOG.md
108
109
  - Gemfile
109
110
  - LICENSE.txt