ffwd 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ffwd/protocol/tcp/flushing_connect.rb +4 -5
- data/lib/ffwd/version.rb +1 -1
- data/lib/fwc.rb +51 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b83d6d295f24ccd855c350f96f7b51ae087c89a
|
4
|
+
data.tar.gz: 43069839db9dcad2026337c4865d23e4bf03f74b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a66bf892b67f376013ea6b1ab9426d241e20ebeb830fb5850ff520c0edd6b20f09296d999e7d839e54bc23f8aecad249a65ba8a04e75cdda0362156ca292d9
|
7
|
+
data.tar.gz: b66d163452d86cf43c44bfbd7696e4b3c5e91dd3bd26a35a05203cf15dfb9b204025c24259cad8f6e14e903a97d1b0d37d08b862ce91373e6a86a23efe6cde6b
|
@@ -71,13 +71,13 @@ module FFWD::TCP
|
|
71
71
|
|
72
72
|
unless ignored.include? :events
|
73
73
|
event_consumer = setup_consumer(
|
74
|
-
@event_buffer,
|
74
|
+
@event_buffer, event_limit, forced_flush_factor, :dropped_events)
|
75
75
|
@subs << core.output.event_subscribe(&event_consumer)
|
76
76
|
end
|
77
77
|
|
78
78
|
unless ignored.include? :metrics
|
79
79
|
metric_consumer = setup_consumer(
|
80
|
-
@metric_buffer,
|
80
|
+
@metric_buffer, metric_limit, forced_flush_factor, :dropped_metrics)
|
81
81
|
@subs << core.output.metric_subscribe(&metric_consumer)
|
82
82
|
end
|
83
83
|
end
|
@@ -130,9 +130,8 @@ module FFWD::TCP
|
|
130
130
|
|
131
131
|
private
|
132
132
|
|
133
|
-
def setup_consumer buffer,
|
134
|
-
|
135
|
-
forced_flush_limit = drop * flush
|
133
|
+
def setup_consumer buffer, drop_limit, forced_flush_factor, statistics_key
|
134
|
+
forced_flush_limit = drop_limit * forced_flush_factor
|
136
135
|
|
137
136
|
proc do |e|
|
138
137
|
if buffer.size >= drop_limit
|
data/lib/ffwd/version.rb
CHANGED
data/lib/fwc.rb
CHANGED
@@ -61,7 +61,9 @@ module FWC
|
|
61
61
|
:summary => false,
|
62
62
|
:raw => false,
|
63
63
|
:raw_threshold => 100,
|
64
|
-
:report_interval => 10
|
64
|
+
:report_interval => 10,
|
65
|
+
:key => nil,
|
66
|
+
:tags => nil
|
65
67
|
}
|
66
68
|
end
|
67
69
|
|
@@ -88,6 +90,15 @@ module FWC
|
|
88
90
|
o.on "-i", "--report-interval", "Interval in seconds to generate report" do |d|
|
89
91
|
opts[:report_interval] = d.to_i
|
90
92
|
end
|
93
|
+
|
94
|
+
o.on "--key <key>", "Only handle events and metrics matching the specified key" do |d|
|
95
|
+
opts[:key] = d
|
96
|
+
end
|
97
|
+
|
98
|
+
o.on "--tag <tag>", "Only handle event and metrics which matches the specified tag" do |d|
|
99
|
+
opts[:tags] ||= []
|
100
|
+
opts[:tags] << d
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
93
104
|
|
@@ -96,7 +107,8 @@ module FWC
|
|
96
107
|
end
|
97
108
|
|
98
109
|
class Summary
|
99
|
-
def initialize
|
110
|
+
def initialize matcher
|
111
|
+
@matcher = matcher
|
100
112
|
@groups = {}
|
101
113
|
end
|
102
114
|
|
@@ -119,6 +131,8 @@ module FWC
|
|
119
131
|
end
|
120
132
|
|
121
133
|
def receive data
|
134
|
+
return if not @matcher.matches? data
|
135
|
+
|
122
136
|
id = [data["id"], data["type"]]
|
123
137
|
group = (@groups[id] ||= {:id => data["id"], :type => data["type"],
|
124
138
|
:items => {}})
|
@@ -135,8 +149,9 @@ module FWC
|
|
135
149
|
end
|
136
150
|
|
137
151
|
class Raw
|
138
|
-
def initialize
|
139
|
-
@threshold = threshold
|
152
|
+
def initialize matcher, opts={}
|
153
|
+
@threshold = opts[:threshold]
|
154
|
+
@matcher = matcher
|
140
155
|
@count = 0
|
141
156
|
@rate = 0
|
142
157
|
@disabled = false
|
@@ -155,6 +170,12 @@ module FWC
|
|
155
170
|
end
|
156
171
|
|
157
172
|
def receive data
|
173
|
+
return if not @matcher.matches? data
|
174
|
+
|
175
|
+
if not @tags.nil? and not (@tags & (d["tags"] || [])).empty?
|
176
|
+
return
|
177
|
+
end
|
178
|
+
|
158
179
|
if not @disabled and @count > 100
|
159
180
|
diff = (Time.now - @first)
|
160
181
|
rate = (@count / diff)
|
@@ -175,17 +196,41 @@ module FWC
|
|
175
196
|
end
|
176
197
|
end
|
177
198
|
|
199
|
+
class Matcher
|
200
|
+
def initialize opts={}
|
201
|
+
@key = opts[:key]
|
202
|
+
@tags = opts[:tags]
|
203
|
+
end
|
204
|
+
|
205
|
+
def matches? data
|
206
|
+
return false unless ["event", "metric"].include? data["type"]
|
207
|
+
|
208
|
+
d = data["data"]
|
209
|
+
return false unless d
|
210
|
+
|
211
|
+
key = d["key"]
|
212
|
+
return false if @key and @key != key
|
213
|
+
|
214
|
+
tags = d["tags"]
|
215
|
+
return false if @tags and (@tags & (tags || [])).empty?
|
216
|
+
|
217
|
+
true
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
178
221
|
def self.main(args)
|
179
222
|
parse_options args
|
180
223
|
|
224
|
+
matcher = Matcher.new(:key => opts[:key], :tags => opts[:tags])
|
225
|
+
|
181
226
|
handlers = []
|
182
227
|
|
183
228
|
if opts[:summary]
|
184
|
-
handlers << Summary.new
|
229
|
+
handlers << Summary.new(matcher)
|
185
230
|
end
|
186
231
|
|
187
232
|
if opts[:raw]
|
188
|
-
handlers << Raw.new(opts[:raw_threshold])
|
233
|
+
handlers << Raw.new(matcher, :threshold => opts[:raw_threshold])
|
189
234
|
end
|
190
235
|
|
191
236
|
if handlers.empty?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffwd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John-John Tedro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|