Module: FWC
Defined Under Namespace
Classes: Matcher, Raw, Summary, TraceConnection
Class Method Summary
collapse
Class Method Details
.log ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/fwc.rb', line 25
def self.log
@logger ||= ::Logger.new(STDOUT).tap do |l|
l.level = Logger::INFO
l.formatter = proc do |severity, datetime, progname, msg|
t = datetime.strftime("%H:%M:%S")
"#{t} #{severity}: #{msg}\n"
end
end
end
|
.main(args) ⇒ Object
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/fwc.rb', line 221
def self.main(args)
parse_options args
matcher = Matcher.new(:key => opts[:key], :tags => opts[:tags])
handlers = []
if opts[:summary]
handlers << Summary.new(matcher)
end
if opts[:raw]
handlers << Raw.new(matcher, :threshold => opts[:raw_threshold])
end
if handlers.empty?
puts "No methods specified"
return 1
end
EM.run do
EM.connect(opts[:host], opts[:port], FWC::TraceConnection, handlers)
EM::PeriodicTimer.new(opts[:report_interval]) do
handlers.each(&:report!)
end
end
return 0
end
|
.opts ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/fwc.rb', line 56
def self.opts
@@opts ||= {
:debug => false,
:host => "localhost",
:port => FFWD::Debug::DEFAULT_PORT,
:summary => false,
:raw => false,
:raw_threshold => 100,
:report_interval => 10,
:key => nil,
:tags => nil
}
end
|
.parse_options(args) ⇒ Object
105
106
107
|
# File 'lib/fwc.rb', line 105
def self.parse_options(args)
parser.parse args
end
|
.parser ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/fwc.rb', line 70
def self.parser
@@parser ||= OptionParser.new do |o|
o.banner = "Usage: fwc [options]"
o.on "-d", "--[no-]debug" do |d|
opts[:debug] = d
end
o.on "-s", "--summary", "Show a periodic summary of everything seen" do
opts[:summary] = true
end
o.on "-r", "--raw", "Display raw metrics and events, as soon as they are seen" do
opts[:raw] = true
end
o.on "--raw-threshold <rate>", "Limit of how many messages/s is allowed before disabling output" do |d|
opts[:raw_threshold] = d.to_i
end
o.on "-i", "--report-interval", "Interval in seconds to generate report" do |d|
opts[:report_interval] = d.to_i
end
o.on "--key <key>", "Only handle events and metrics matching the specified key" do |d|
opts[:key] = d
end
o.on "--tag <tag>", "Only handle event and metrics which matches the specified tag" do |d|
opts[:tags] ||= []
opts[:tags] << d
end
end
end
|