Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Log instrumentation name for exists? queries #1823

Merged
merged 1 commit into from

4 participants

@gnarg

Hi,

I noticed that as of 3.1 exists? queries stopped reporting an instrumentation name in their log entry. Here's a proposed patch for that.

Thanks,
Jon
Ruby Agent Engineer
New Relic

@sikachu
Collaborator

Looks good. @tenderlove do you mind picking this in? (If all the tests passed?)

@pixeltrix
Owner

It stopped being reported a long time ago.

@sikachu
Collaborator

Nice find! haha

@pixeltrix pixeltrix was assigned
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@smtlaissezfaire smtlaissezfaire Controller, response, and request should all refer to same session, e…
…ven after a call to session_reset [#1823 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2dedb5b
@spastorino spastorino merged commit c3732bf into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 22, 2011
  1. Log instrumentation name for exists? queries

    Jon Guymon authored
This page is out of date. Refresh to see the latest.
View
4 activerecord/lib/active_record/relation/finder_methods.rb
@@ -193,8 +193,8 @@ def exists?(id = nil)
else
relation = relation.where(table[primary_key].eq(id)) if id
end
-
- connection.select_value(relation.to_sql) ? true : false
+
+ connection.select_value(relation.to_sql, "#{name} Exists") ? true : false
end
protected
View
8 activerecord/test/cases/log_subscriber_test.rb
@@ -63,6 +63,14 @@ def test_basic_query_logging
assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last)
end
+ def test_exists_query_logging
+ Developer.exists? 1
+ wait
+ assert_equal 1, @logger.logged(:debug).size
+ assert_match(/Developer Exists/, @logger.logged(:debug).last)
+ assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last)
+ end
+
def test_cached_queries
ActiveRecord::Base.cache do
Developer.all
Something went wrong with that request. Please try again.