Module: Resque::Plugins::Logstash
- Extended by:
- Forwardable
- Defined in:
- lib/resque/logstash/version.rb,
lib/resque/logstash/transport/redis.rb,
lib/resque/logstash/config.rb,
lib/resque/logstash.rb
Defined Under Namespace
Modules: Transport
Classes: Config
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.config ⇒ Object
22
23
24
|
# File 'lib/resque/logstash.rb', line 22
def config
@config ||= Config.new
end
|
18
19
20
|
# File 'lib/resque/logstash.rb', line 18
def configure
yield config
end
|
Instance Method Details
27
28
29
30
31
32
33
34
|
# File 'lib/resque/logstash.rb', line 27
def around_perform_logstash_measure(*args)
started_at = Time.now
yield
rescue Exception => e
raise
ensure
logstash_push_duration Time.now - started_at, args, e
end
|
#logstash_create_event(duration, args, exception) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/resque/logstash.rb', line 41
def logstash_create_event(duration, args, exception)
if exception.nil?
params = {'status' => 'success'}
verb = 'finished'
else
params = {
'status' => 'failure',
'exception' => "#{exception.class}: #{exception.message}"
}
verb = 'failed'
end
params = params.merge "message" => "Job #{self.name} #{verb} in #{duration}s",
"job" => self.name,
"duration" => duration,
"job_arguments" => args.map { |a| a.to_s },
"tags" => Logstash.config.tags
LogStash::Event.new params
end
|
#logstash_push_duration(duration, args, exception) ⇒ Object
36
37
38
39
|
# File 'lib/resque/logstash.rb', line 36
def logstash_push_duration(duration, args, exception)
return if Logstash.config.disabled?
Logstash.config.transport.push logstash_create_event(duration, args, exception)
end
|