Class: Airbrake::Rails::Event Private

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/airbrake/rails/event.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Event is a wrapper around ActiveSupport::Notifications::Event.

Since:

  • v9.0.3

Constant Summary collapse

HTML_RESPONSE_WILDCARD =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"*/*"

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Event

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Event.

Since:

  • v9.0.3



15
16
17
# File 'lib/airbrake/rails/event.rb', line 15

def initialize(*args)
  @event = ActiveSupport::Notifications::Event.new(*args)
end

Instance Method Details

#db_runtimeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



36
37
38
# File 'lib/airbrake/rails/event.rb', line 36

def db_runtime
  @db_runtime ||= @event.payload[:db_runtime] || 0
end

#durationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



76
77
78
# File 'lib/airbrake/rails/event.rb', line 76

def duration
  @event.duration
end

#groupsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



48
49
50
51
52
53
# File 'lib/airbrake/rails/event.rb', line 48

def groups
  groups = {}
  groups[:db] = db_runtime if db_runtime > 0
  groups[:view] = view_runtime if view_runtime > 0
  groups
end

#methodObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



19
20
21
# File 'lib/airbrake/rails/event.rb', line 19

def method
  @event.payload[:method]
end

#paramsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



28
29
30
# File 'lib/airbrake/rails/event.rb', line 28

def params
  @event.payload[:params]
end

#response_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



23
24
25
26
# File 'lib/airbrake/rails/event.rb', line 23

def response_type
  response_type = @event.payload[:format]
  response_type == HTML_RESPONSE_WILDCARD ? :html : response_type
end

#sqlObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



32
33
34
# File 'lib/airbrake/rails/event.rb', line 32

def sql
  @event.payload[:sql]
end

#status_codeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/airbrake/rails/event.rb', line 55

def status_code
  return @event.payload[:status] if @event.payload[:status]

  if @event.payload[:exception]
    status = ActionDispatch::ExceptionWrapper.status_code_for_exception(
      @event.payload[:exception].first,
    )
    status = 500 if status == 0

    return status
  end

  # The ActiveSupport event doesn't have status only in two cases:
  #   - an exception was thrown
  #   - unauthorized access
  # We have already handled the exception so what's left is unauthorized
  # access. There's no way to know for sure it's unauthorized access, so
  # we are rather optimistic here.
  401
end

#timeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



44
45
46
# File 'lib/airbrake/rails/event.rb', line 44

def time
  @event.time
end

#view_runtimeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v9.0.3



40
41
42
# File 'lib/airbrake/rails/event.rb', line 40

def view_runtime
  @view_runtime ||= @event.payload[:view_runtime] || 0
end