Class: Airbrake::Query

Inherits:
Object
  • Object
show all
Includes:
Grouppable, HashKeyable, Ignorable, Mergeable, Stashable
Defined in:
lib/airbrake-ruby/query.rb

Overview

Query holds SQL query data that powers SQL query collection.

rubocop:disable Metrics/ParameterLists

See Also:

Since:

  • v3.2.0

Instance Attribute Summary collapse

Attributes included from Ignorable

#ignored

Instance Method Summary collapse

Methods included from Grouppable

#groups

Methods included from Mergeable

#merge

Methods included from Stashable

#stash

Methods included from Ignorable

#ignore!, #ignored?

Methods included from HashKeyable

#eql?, #hash

Constructor Details

#initialize(method:, route:, query:, func: nil, file: nil, line: nil, timing: nil, time: Time.now) ⇒ Query

Returns a new instance of Query.

Since:

  • v3.2.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/airbrake-ruby/query.rb', line 17

def initialize(
  method:,
  route:,
  query:,
  func: nil,
  file: nil,
  line: nil,
  timing: nil,
  time: Time.now
)
  @time_utc = TimeTruncate.utc_truncate_minutes(time)
  @method = method
  @route = route
  @query = query
  @func = func
  @file = file
  @line = line
  @timing = timing
  @time = time
end

Instance Attribute Details

#fileObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def file
  @file
end

#funcObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def func
  @func
end

#lineObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def line
  @line
end

#methodObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def method
  @method
end

#queryObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def query
  @query
end

#routeObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def route
  @route
end

#timeObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def time
  @time
end

#timingObject

Since:

  • v3.2.0



15
16
17
# File 'lib/airbrake-ruby/query.rb', line 15

def timing
  @timing
end

Instance Method Details

#cargoObject

Since:

  • v3.2.0



42
43
44
# File 'lib/airbrake-ruby/query.rb', line 42

def cargo
  'queries'
end

#destinationObject

Since:

  • v3.2.0



38
39
40
# File 'lib/airbrake-ruby/query.rb', line 38

def destination
  'queries-stats'
end

#to_hObject

Since:

  • v3.2.0



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/airbrake-ruby/query.rb', line 46

def to_h
  {
    'method' => method,
    'route' => route,
    'query' => query,
    'time' => @time_utc,
    'function' => func,
    'file' => file,
    'line' => line,
  }.delete_if { |_key, val| val.nil? }
end