Class: Timber::Events::SQLQuery
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::SQLQuery
- Defined in:
- lib/timber/events/sql_query.rb
Overview
Note:
This event should be installed automatically through probes, such as the Probes::ActiveRecordLogSubscriber probe.
The SQL query event tracks sql queries to your database.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
-
#time_ms ⇒ Object
readonly
Returns the value of attribute time_ms.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ SQLQuery
constructor
A new instance of SQLQuery.
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ SQLQuery
Returns a new instance of SQLQuery.
10 11 12 13 14 15 |
# File 'lib/timber/events/sql_query.rb', line 10 def initialize(attributes) @sql = attributes[:sql] || raise(ArgumentError.new(":sql is required")) @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required")) @time_ms = @time_ms.round(6) @message = attributes[:message] || raise(ArgumentError.new(":message is required")) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/timber/events/sql_query.rb', line 8 def @message end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
8 9 10 |
# File 'lib/timber/events/sql_query.rb', line 8 def sql @sql end |
#time_ms ⇒ Object (readonly)
Returns the value of attribute time_ms.
8 9 10 |
# File 'lib/timber/events/sql_query.rb', line 8 def time_ms @time_ms end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
22 23 24 |
# File 'lib/timber/events/sql_query.rb', line 22 def as_json( = {}) {:server_side_app => {:sql_query => to_hash}} end |
#to_hash ⇒ Object Also known as: to_h
17 18 19 |
# File 'lib/timber/events/sql_query.rb', line 17 def to_hash {sql: sql, time_ms: time_ms} end |