Class: Airbrake::Request

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

Overview

Request holds request data that powers route stats.

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:, status_code:, timing: nil, time: Time.now) ⇒ Request

Returns a new instance of Request.

Since:

  • v3.2.0



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/airbrake-ruby/request.rb', line 16

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

Instance Attribute Details

#methodObject

Since:

  • v3.2.0



14
15
16
# File 'lib/airbrake-ruby/request.rb', line 14

def method
  @method
end

#routeObject

Since:

  • v3.2.0



14
15
16
# File 'lib/airbrake-ruby/request.rb', line 14

def route
  @route
end

#status_codeObject

Since:

  • v3.2.0



14
15
16
# File 'lib/airbrake-ruby/request.rb', line 14

def status_code
  @status_code
end

#timeObject

Since:

  • v3.2.0



14
15
16
# File 'lib/airbrake-ruby/request.rb', line 14

def time
  @time
end

#timingObject

Since:

  • v3.2.0



14
15
16
# File 'lib/airbrake-ruby/request.rb', line 14

def timing
  @timing
end

Instance Method Details

#cargoObject

Since:

  • v3.2.0



35
36
37
# File 'lib/airbrake-ruby/request.rb', line 35

def cargo
  'routes'
end

#destinationObject

Since:

  • v3.2.0



31
32
33
# File 'lib/airbrake-ruby/request.rb', line 31

def destination
  'routes-stats'
end

#to_hObject

Since:

  • v3.2.0



39
40
41
42
43
44
45
46
# File 'lib/airbrake-ruby/request.rb', line 39

def to_h
  {
    'method' => method,
    'route' => route,
    'statusCode' => status_code,
    'time' => @time_utc,
  }.delete_if { |_key, val| val.nil? }
end