Module: Resque::Plugins::Statsd

Defined in:
lib/resque-statsd.rb,
lib/resque/plugins/statsd.rb

Constant Summary collapse

VERSION =
"0.0.4"

Instance Method Summary collapse

Instance Method Details

#after_enqueue_statsd(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/resque/plugins/statsd.rb', line 4

def after_enqueue_statsd(*args)
  StatsdHelper.statsd.increment("queues.#{@queue}.enqueued")
  StatsdHelper.statsd.increment("jobs.#{self.name}.enqueued")
  StatsdHelper.statsd.increment("total.enqueued")
rescue SocketError => se
  # Common cause of this is failure of getaddrinfo (I.E. can't route to
  # statsd server or some such).  This may happen in development, when
  # your net connection isn't in a good way, for example.
  #
  # Ignoring this because we don't want unreachability of statsd to
  # impair the ability of an app to actually operate.
end

#after_perform_statsd(*args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/resque/plugins/statsd.rb', line 30

def after_perform_statsd(*args)
  StatsdHelper.statsd.increment("queues.#{@queue}.finished")
  StatsdHelper.statsd.increment("jobs.#{self.name}.finished")
  StatsdHelper.statsd.increment("total.finished")
rescue SocketError => se
  # Common cause of this is failure of getaddrinfo (I.E. can't route to
  # statsd server or some such).  This may happen in development, when
  # your net connection isn't in a good way, for example.
  #
  # Ignoring this because we don't want unreachability of statsd to
  # impair the ability of an app to actually operate.
end

#around_perform_statsd(*args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/resque/plugins/statsd.rb', line 56

def around_perform_statsd(*args)
  # We don't want to swallow a SocketError if it didn't actually come
  # from our attempts to talk to statsd.
  failure_is_in_app = true
  StatsdHelper.statsd.time("queues.#{@queue}.processed") do
    StatsdHelper.statsd.time("jobs.#{self.name}.processed") do
      yield
      failure_is_in_app = false
    end
  end
rescue SocketError => se
  # Common cause of this is failure of getaddrinfo (I.E. can't route to
  # statsd server or some such).  This may happen in development, when
  # your net connection isn't in a good way, for example.
  #
  # Ignoring this iff it's statsd-related because we don't want
  # unreachability of statsd to impair the ability of an app to actually
  # operate.
  raise se if(failure_is_in_app)
end

#before_perform_statsd(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/resque/plugins/statsd.rb', line 17

def before_perform_statsd(*args)
  StatsdHelper.statsd.increment("queues.#{@queue}.started")
  StatsdHelper.statsd.increment("jobs.#{self.name}.started")
  StatsdHelper.statsd.increment("total.started")
rescue SocketError => se
  # Common cause of this is failure of getaddrinfo (I.E. can't route to
  # statsd server or some such).  This may happen in development, when
  # your net connection isn't in a good way, for example.
  #
  # Ignoring this because we don't want unreachability of statsd to
  # impair the ability of an app to actually operate.
end

#on_failure_statsd(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/resque/plugins/statsd.rb', line 43

def on_failure_statsd(*args)
  StatsdHelper.statsd.increment("queues.#{@queue}.failed")
  StatsdHelper.statsd.increment("jobs.#{self.name}.failed")
  StatsdHelper.statsd.increment("total.failed")
rescue SocketError => se
  # Common cause of this is failure of getaddrinfo (I.E. can't route to
  # statsd server or some such).  This may happen in development, when
  # your net connection isn't in a good way, for example.
  #
  # Ignoring this because we don't want unreachability of statsd to
  # impair the ability of an app to actually operate.
end