Class: Airbrake::Queue

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

Overview

Queue represents a queue (worker).

See Also:

Since:

  • v4.9.0

Instance Attribute Summary collapse

Attributes included from Ignorable

#ignored

Instance Method Summary collapse

Methods included from Stashable

#stash

Methods included from Ignorable

#ignore!, #ignored?

Methods included from HashKeyable

#eql?

Constructor Details

#initialize(queue:, error_count:, groups: {}, timing: nil, time: Time.now) ⇒ Queue

Returns a new instance of Queue.

Since:

  • v4.9.0



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

def initialize(
  queue:,
  error_count:,
  groups: {},
  timing: nil,
  time: Time.now
)
  @time_utc = TimeTruncate.utc_truncate_minutes(time)
  @queue = queue
  @error_count = error_count
  @groups = groups
  @timing = timing
  @time = time
end

Instance Attribute Details

#error_countObject

Since:

  • v4.9.0



12
13
14
# File 'lib/airbrake-ruby/queue.rb', line 12

def error_count
  @error_count
end

#groupsObject

Since:

  • v4.9.0



12
13
14
# File 'lib/airbrake-ruby/queue.rb', line 12

def groups
  @groups
end

#queueObject

Since:

  • v4.9.0



12
13
14
# File 'lib/airbrake-ruby/queue.rb', line 12

def queue
  @queue
end

#timeObject

Since:

  • v4.9.0



12
13
14
# File 'lib/airbrake-ruby/queue.rb', line 12

def time
  @time
end

#timingObject

Since:

  • v4.9.0



12
13
14
# File 'lib/airbrake-ruby/queue.rb', line 12

def timing
  @timing
end

Instance Method Details

#cargoObject

Since:

  • v4.9.0



33
34
35
# File 'lib/airbrake-ruby/queue.rb', line 33

def cargo
  'queues'
end

#destinationObject

Since:

  • v4.9.0



29
30
31
# File 'lib/airbrake-ruby/queue.rb', line 29

def destination
  'queues-stats'
end

#hashObject

Since:

  • v4.9.0



45
46
47
48
49
50
# File 'lib/airbrake-ruby/queue.rb', line 45

def hash
  {
    'queue' => queue,
    'time' => @time_utc,
  }.hash
end

#merge(other) ⇒ Object

Since:

  • v4.9.0



52
53
54
# File 'lib/airbrake-ruby/queue.rb', line 52

def merge(other)
  self.error_count += other.error_count
end

#routeString

Queues don’t have routes, but we want to define this to make sure our filter API is consistent (other models define this property)

Returns:

  • (String)

    empty route

See Also:

Since:

  • v4.9.0



61
62
63
# File 'lib/airbrake-ruby/queue.rb', line 61

def route
  ''
end

#to_hObject

Since:

  • v4.9.0



37
38
39
40
41
42
43
# File 'lib/airbrake-ruby/queue.rb', line 37

def to_h
  {
    'queue' => queue,
    'errorCount' => error_count,
    'time' => @time_utc,
  }
end