ffwd 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ffwd/flushing_output.rb +149 -0
- data/lib/ffwd/flushing_output_hook.rb +48 -0
- data/lib/ffwd/plugin_channel.rb +3 -1
- data/lib/ffwd/processor/count.rb +4 -4
- data/lib/ffwd/processor/histogram.rb +5 -4
- data/lib/ffwd/processor/rate.rb +5 -4
- data/lib/ffwd/producing_client.rb +19 -13
- data/lib/ffwd/protocol/tcp/bind.rb +5 -8
- data/lib/ffwd/protocol/tcp/connection.rb +1 -1
- data/lib/ffwd/protocol/tcp/flushing_connect.rb +12 -6
- data/lib/ffwd/protocol/tcp/plain_connect.rb +11 -6
- data/lib/ffwd/protocol/udp/bind.rb +8 -8
- data/lib/ffwd/protocol/udp/connect.rb +8 -7
- data/lib/ffwd/reporter.rb +36 -16
- data/lib/ffwd/statistics/collector.rb +4 -5
- data/lib/ffwd/tunnel/tcp.rb +7 -2
- data/lib/ffwd/tunnel/udp.rb +7 -2
- data/lib/ffwd/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69e61111c5686efc942cdde2b5478c95b5575fe5
|
4
|
+
data.tar.gz: 038e9a560c4388d42726684edafad3b0f605fd27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c534a19834fb159a982058bb2f9f8c2b80a409a2e01f385f3ec8c4c86e788b05bff2faa170338e739c49021ad5e5d7179f4f47881aacee8c0415c5099b6497a
|
7
|
+
data.tar.gz: c579ee941ace40659f19faef1e5e911be655746ecace89126f6e268672b1530f7d800337c74547679df6c2a6717105282cb41c76b0f53dd7b81c416f78dfcb6a
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'ffwd/reporter'
|
17
|
+
|
18
|
+
require_relative 'utils'
|
19
|
+
|
20
|
+
module FFWD
|
21
|
+
class FlushingOutput
|
22
|
+
include FFWD::Reporter
|
23
|
+
|
24
|
+
report_meta :direction => :out
|
25
|
+
|
26
|
+
report_key :dropped_metrics, :meta => {:what => :dropped_metrics, :unit => :metric}
|
27
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
28
|
+
report_key :sent_metrics, :meta => {:what => :sent_metrics, :unit => :metric}
|
29
|
+
|
30
|
+
attr_reader :log, :reporter_meta
|
31
|
+
|
32
|
+
def initialize core, log, hook, config
|
33
|
+
@log = log
|
34
|
+
@flush_interval = config[:flush_interval]
|
35
|
+
@buffer_limit = config[:buffer_limit]
|
36
|
+
@hook = hook
|
37
|
+
@reporter_meta = @hook.reporter_meta
|
38
|
+
|
39
|
+
@buffer = []
|
40
|
+
@pending = nil
|
41
|
+
@c = nil
|
42
|
+
|
43
|
+
@sub = nil
|
44
|
+
|
45
|
+
core.starting do
|
46
|
+
@log.info "Started"
|
47
|
+
@log.info " config: #{config}"
|
48
|
+
|
49
|
+
@hook.connect
|
50
|
+
|
51
|
+
@sub = core.output.metric_subscribe do |metric|
|
52
|
+
if @buffer.size >= @buffer_limit
|
53
|
+
increment :dropped_metrics, 1
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
@buffer << metric
|
58
|
+
check_timer!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
core.stopping do
|
63
|
+
@log.info "Stopped"
|
64
|
+
|
65
|
+
@hook.close
|
66
|
+
|
67
|
+
if @sub
|
68
|
+
@sub.unsubscribe
|
69
|
+
@sub = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
if @timer
|
73
|
+
@timer.cancel
|
74
|
+
@timer = nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def flush!
|
80
|
+
if @timer
|
81
|
+
@timer.cancel
|
82
|
+
@timer = nil
|
83
|
+
end
|
84
|
+
|
85
|
+
if @pending
|
86
|
+
@log.info "Request already in progress, dropping metrics"
|
87
|
+
increment :dropped_metrics, @buffer.size
|
88
|
+
@buffer.clear
|
89
|
+
return
|
90
|
+
end
|
91
|
+
|
92
|
+
unless @hook.active?
|
93
|
+
@log.error "Dropping metrics, no active connection available"
|
94
|
+
increment :dropped_metrics, @buffer.size
|
95
|
+
@buffer.clear
|
96
|
+
return
|
97
|
+
end
|
98
|
+
|
99
|
+
buffer_size = @buffer.size
|
100
|
+
|
101
|
+
@pending = @hook.send @buffer
|
102
|
+
|
103
|
+
@pending.callback do
|
104
|
+
increment :sent_metrics, buffer_size
|
105
|
+
@pending = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
@pending.errback do
|
109
|
+
@log.error "Failed to submit metrics: #{@pending.error}"
|
110
|
+
increment :failed_metrics, buffer_size
|
111
|
+
@pending = nil
|
112
|
+
end
|
113
|
+
rescue => e
|
114
|
+
@log.error "Error during flush", e
|
115
|
+
ensure
|
116
|
+
@buffer.clear
|
117
|
+
end
|
118
|
+
|
119
|
+
def check_timer!
|
120
|
+
return if @timer
|
121
|
+
|
122
|
+
@log.debug "Setting timer to #{@flush_interval}s"
|
123
|
+
|
124
|
+
@timer = EM::Timer.new(@flush_interval) do
|
125
|
+
flush!
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
class Setup
|
130
|
+
attr_reader :config
|
131
|
+
|
132
|
+
def initialize log, hook, config
|
133
|
+
@log = log
|
134
|
+
@hook = hook
|
135
|
+
@config = config
|
136
|
+
end
|
137
|
+
|
138
|
+
def connect core
|
139
|
+
FlushingOutput.new core, @log, @hook, @config
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.flushing_output log, hook, config={}
|
145
|
+
raise "Expected: flush_interval" unless config[:flush_interval]
|
146
|
+
raise "Expected: buffer_limit" unless config[:buffer_limit]
|
147
|
+
FlushingOutput::Setup.new log, hook, config
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module FFWD
|
17
|
+
class FlushingOutputHook
|
18
|
+
# Establish connections.
|
19
|
+
def connect
|
20
|
+
raise "not implemented: connect"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Close any open connections.
|
24
|
+
def close
|
25
|
+
raise "not implemented: close"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return true if connection is accessible, false otherwise.
|
29
|
+
def active?
|
30
|
+
raise "not implemented: active?"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Send the specified batch of metrics.
|
34
|
+
#
|
35
|
+
# Must return a callback object with the following attributes.
|
36
|
+
# callback - That accepts a block that will be run on successful execution.
|
37
|
+
# errback - That accepts a block that will be run on failed execution.
|
38
|
+
# error - If errback has been triggered, should contain the error that
|
39
|
+
# occured.
|
40
|
+
def send metrics
|
41
|
+
raise "not implemented: send"
|
42
|
+
end
|
43
|
+
|
44
|
+
def reporter_meta
|
45
|
+
{}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/ffwd/plugin_channel.rb
CHANGED
@@ -26,7 +26,9 @@ module FFWD
|
|
26
26
|
include FFWD::Reporter
|
27
27
|
include FFWD::Logging
|
28
28
|
|
29
|
-
|
29
|
+
report_meta :component => :plugin_channel
|
30
|
+
report_key :metrics, :meta => {:what => :metrics, :unit => :metric}
|
31
|
+
report_key :events, :meta => {:what => :events, :unit => :event}
|
30
32
|
|
31
33
|
attr_reader :id, :events, :metrics, :reporter_meta
|
32
34
|
|
data/lib/ffwd/processor/count.rb
CHANGED
@@ -29,10 +29,10 @@ module FFWD::Processor
|
|
29
29
|
include FFWD::Reporter
|
30
30
|
|
31
31
|
register_processor "count"
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
|
33
|
+
report_meta :component => :processor, :processor => :count
|
34
|
+
report_key :dropped, :meta => {:what => :count_dropped, :unit => :value}
|
35
|
+
report_key :received, :meta => {:what => :count_received, :unit => :value}
|
36
36
|
|
37
37
|
def self.prepare config
|
38
38
|
config[:cache_limit] ||= 1000
|
@@ -41,10 +41,11 @@ module FFWD::Processor
|
|
41
41
|
include FFWD::Reporter
|
42
42
|
|
43
43
|
register_processor "histogram"
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
|
45
|
+
report_meta :component => :processor, :processor => :histogram
|
46
|
+
report_key :dropped, {:meta => {:what => :dropped, :unit => :value}}
|
47
|
+
report_key :bucket_dropped, {:meta => {:what => :bucket_dropped, :unit => :value}}
|
48
|
+
report_key :received, {:meta => {:what => :received, :unit => :value}}
|
48
49
|
|
49
50
|
DEFAULT_MISSING = 0
|
50
51
|
|
data/lib/ffwd/processor/rate.rb
CHANGED
@@ -27,10 +27,11 @@ module FFWD::Processor
|
|
27
27
|
include FFWD::Reporter
|
28
28
|
|
29
29
|
register_processor "rate"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
|
31
|
+
report_meta :component => :processor, :processor => :rate
|
32
|
+
report_key :dropped, {:meta => {:what => :dropped, :unit => :value}}
|
33
|
+
report_key :expired, {:meta => {:what => :expired, :unit => :value}}
|
34
|
+
report_key :received, {:meta => {:what => :received, :unit => :value}}
|
34
35
|
|
35
36
|
# Options:
|
36
37
|
#
|
@@ -29,21 +29,27 @@ module FFWD
|
|
29
29
|
def produce events, metrics; raise "not implemented: produce"; end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
report_meta :component => :producing_client
|
33
|
+
|
34
|
+
# number of events/metrics that we attempted to dispatch but failed.
|
35
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
36
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
37
|
+
|
38
|
+
# number of events/metrics that were dropped because the output buffers
|
39
|
+
# are full.
|
40
|
+
report_key :dropped_events, :meta => {:what => :dropped_events, :unit => :event}
|
41
|
+
report_key :dropped_metrics, :meta => {:what => :dropped_metrics, :unit => :event}
|
42
|
+
|
43
|
+
# number of events/metrics successfully sent.
|
44
|
+
report_key :sent_events, :meta => {:what => :sent_events, :unit => :event}
|
45
|
+
report_key :sent_metrics, :meta => {:what => :sent_metrics, :unit => :event}
|
46
|
+
|
47
|
+
# number of requests that take longer than the allowed period.
|
48
|
+
report_key :slow_requests, :meta => {:what => :slow_requests, :unit => :request}
|
43
49
|
|
44
50
|
def reporter_meta
|
45
|
-
|
46
|
-
|
51
|
+
return {} if @producer_is_reporter
|
52
|
+
@producer.class.reporter_meta.merge(@producer.reporter_meta)
|
47
53
|
end
|
48
54
|
|
49
55
|
def report!
|
@@ -30,20 +30,17 @@ module FFWD::TCP
|
|
30
30
|
opts
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
report_meta :protocol => :tcp, :direction => :in
|
34
|
+
|
35
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
36
|
+
report_key :received_events, :meta => {:what => :received_events, :unit => :event}
|
37
37
|
|
38
38
|
attr_reader :log, :reporter_meta
|
39
39
|
|
40
40
|
def initialize core, log, host, port, connection, config
|
41
41
|
@log = log
|
42
42
|
@peer = "#{host}:#{port}"
|
43
|
-
@reporter_meta = {
|
44
|
-
:type => connection.plugin_type,
|
45
|
-
:listen => @peer, :family => 'tcp'
|
46
|
-
}
|
43
|
+
@reporter_meta = {:component => connection.plugin_type, :listen => @peer}
|
47
44
|
|
48
45
|
@server = nil
|
49
46
|
|
@@ -46,7 +46,7 @@ module FFWD::TCP
|
|
46
46
|
@peer = "#{host}:#{port}"
|
47
47
|
@closing = false
|
48
48
|
@reconnect_timeout = INITIAL_TIMEOUT
|
49
|
-
@reporter_meta = {:
|
49
|
+
@reporter_meta = {:component => @handler.plugin_type, :peer => peer}
|
50
50
|
|
51
51
|
@timer = nil
|
52
52
|
@c = nil
|
@@ -29,12 +29,18 @@ module FFWD::TCP
|
|
29
29
|
# maximum amount of metrics to buffer up.
|
30
30
|
DEFAULT_METRIC_LIMIT = 10000
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
report_meta :protocol => :tcp, :direction => :out
|
33
|
+
|
34
|
+
report_key :dropped_events, :meta => {:what => :dropped_events, :unit => :event}
|
35
|
+
report_key :dropped_metrics, :meta => {:what => :dropped_metrics, :unit => :metric}
|
36
|
+
|
37
|
+
report_key :sent_events, :meta => {:what => :sent_events, :unit => :event}
|
38
|
+
report_key :sent_metrics, :meta => {:what => :sent_metrics, :unit => :metric}
|
39
|
+
|
40
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
41
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
42
|
+
|
43
|
+
report_key :forced_flush, :meta => {:what => :forced_flush, :unit => :flush}
|
38
44
|
|
39
45
|
attr_reader :log
|
40
46
|
|
@@ -19,17 +19,22 @@ module FFWD::TCP
|
|
19
19
|
class PlainConnect
|
20
20
|
include FFWD::Reporter
|
21
21
|
|
22
|
+
attr_reader :log
|
23
|
+
|
22
24
|
def self.prepare opts
|
23
25
|
opts
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
:dropped_events, :dropped_metrics,
|
28
|
-
:sent_events, :sent_metrics,
|
29
|
-
:failed_events, :failed_metrics
|
30
|
-
]
|
28
|
+
report_meta :protocol => :tcp, :direction => :out
|
31
29
|
|
32
|
-
|
30
|
+
report_key :dropped_events, :meta => {:what => :dropped_events, :unit => :event}
|
31
|
+
report_key :dropped_metrics, :meta => {:what => :dropped_metrics, :unit => :metric}
|
32
|
+
|
33
|
+
report_key :sent_events, :meta => {:what => :sent_events, :unit => :event}
|
34
|
+
report_key :sent_metrics, :meta => {:what => :sent_metrics, :unit => :metric}
|
35
|
+
|
36
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
37
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
33
38
|
|
34
39
|
def reporter_meta
|
35
40
|
@c.reporter_meta
|
@@ -32,20 +32,20 @@ module FFWD::UDP
|
|
32
32
|
opts
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
report_meta :protocol => :udp, :direction => :out
|
36
|
+
|
37
|
+
report_key :received_events, :meta => {:what => :received_events, :unit => :event}
|
38
|
+
report_key :received_metrics, :meta => {:what => :received_metrics, :unit => :metric}
|
39
|
+
|
40
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
41
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
39
42
|
|
40
43
|
attr_reader :reporter_meta, :log, :config
|
41
44
|
|
42
45
|
def initialize core, log, host, port, connection, config
|
43
46
|
@log = log
|
44
47
|
@peer = "#{host}:#{port}"
|
45
|
-
@reporter_meta = {
|
46
|
-
:type => connection.plugin_type,
|
47
|
-
:listen => @peer, :family => 'udp'
|
48
|
-
}
|
48
|
+
@reporter_meta = {:type => connection.plugin_type, :listen => @peer}
|
49
49
|
|
50
50
|
rebind_timeout = config[:rebind_timeout]
|
51
51
|
|
@@ -29,10 +29,13 @@ module FFWD::UDP
|
|
29
29
|
|
30
30
|
attr_reader :reporter_meta, :log, :config
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
report_meta :protocol => :udp, :direction => :out
|
33
|
+
|
34
|
+
report_key :sent_events, :meta => {:what => :sent_events, :unit => :event}
|
35
|
+
report_key :sent_metrics, :meta => {:what => :sent_metrics, :unit => :metric}
|
36
|
+
|
37
|
+
report_key :dropped_events, :meta => {:what => :dropped_events, :unit => :event}
|
38
|
+
report_key :dropped_metrics, :meta => {:what => :dropped_metrics, :unit => :metric}
|
36
39
|
|
37
40
|
def initialize core, log, host, port, handler, config
|
38
41
|
@log = log
|
@@ -46,9 +49,7 @@ module FFWD::UDP
|
|
46
49
|
@host_ip = nil
|
47
50
|
@c = nil
|
48
51
|
@peer = "#{host}:#{port}"
|
49
|
-
@reporter_meta = {
|
50
|
-
:type => @handler.plugin_type, :peer => @peer
|
51
|
-
}
|
52
|
+
@reporter_meta = {:component => @handler.plugin_type, :peer => @peer}
|
52
53
|
|
53
54
|
info = "udp://#{@peer}"
|
54
55
|
|
data/lib/ffwd/reporter.rb
CHANGED
@@ -18,23 +18,44 @@ module FFWD::Reporter
|
|
18
18
|
Hash[meta.map{|k, v| [k.to_s, v]}]
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.build_meta instance, k
|
22
|
+
meta = instance.class.reporter_meta || {}
|
23
|
+
|
24
|
+
if instance.respond_to?(:reporter_meta)
|
25
|
+
meta = meta.merge(instance.send(:reporter_meta))
|
26
|
+
end
|
27
|
+
|
28
|
+
return meta.merge(k[:meta])
|
29
|
+
end
|
30
|
+
|
21
31
|
module ClassMethods
|
22
32
|
def reporter_keys
|
23
|
-
@
|
33
|
+
@reporter_keys ||= []
|
24
34
|
end
|
25
35
|
|
36
|
+
# Statically configured metadata.
|
26
37
|
def reporter_meta
|
27
|
-
@
|
38
|
+
@reporter_meta ||= {}
|
28
39
|
end
|
29
40
|
|
30
|
-
|
31
|
-
|
41
|
+
# Configure either static or dynamic metadata.
|
42
|
+
# If a symbol is provided, it is assumed to be the name of the function
|
43
|
+
# that will be used to fetch metadata.
|
44
|
+
# If a Hash is provided, it will be assumed to be the static metadata.
|
45
|
+
def report_meta meta
|
46
|
+
unless meta.is_a? Hash
|
47
|
+
raise "Invalid meta: #{meta.inspect}"
|
48
|
+
end
|
49
|
+
|
50
|
+
@reporter_meta = meta
|
51
|
+
end
|
52
|
+
|
53
|
+
def report_key key, options={}
|
54
|
+
reporter_keys << {:key => key, :meta => options[:meta] || {}}
|
32
55
|
end
|
33
56
|
|
34
57
|
def setup_reporter opts={}
|
35
|
-
|
36
|
-
@_reporter_meta = opts[:reporter_meta]
|
37
|
-
@_reporter_meta_method = opts[:id_method] || :reporter_meta
|
58
|
+
raise "setup_reporter is deprecated, use (report_*) instead!"
|
38
59
|
end
|
39
60
|
end
|
40
61
|
|
@@ -43,23 +64,22 @@ module FFWD::Reporter
|
|
43
64
|
end
|
44
65
|
|
45
66
|
def reporter_data
|
46
|
-
@
|
47
|
-
@_reporter_data ||= Hash[@_reporter_keys.map{|k| [k, 0]}]
|
67
|
+
@_reporter_data ||= Hash[self.class.reporter_keys.map{|k| [k[:key], 0]}]
|
48
68
|
end
|
49
69
|
|
50
70
|
def increment n, c=1
|
51
71
|
reporter_data[n] += c
|
52
|
-
reporter_data[:total] += c
|
53
72
|
end
|
54
73
|
|
55
74
|
def report!
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
reporter_data.each do |k, v|
|
60
|
-
yield(:key => k, :value => v,
|
61
|
-
:meta => @_reporter_meta)
|
75
|
+
self.class.reporter_keys.each do |key|
|
76
|
+
k = key[:key]
|
77
|
+
v = reporter_data[k]
|
62
78
|
reporter_data[k] = 0
|
79
|
+
|
80
|
+
meta = ((@_reporter_meta ||= {})[k] ||= FFWD::Reporter.build_meta(self, key))
|
81
|
+
|
82
|
+
yield(:key => k, :value => v, :meta => meta)
|
63
83
|
end
|
64
84
|
end
|
65
85
|
end
|
@@ -80,19 +80,18 @@ module FFWD::Statistics
|
|
80
80
|
def generate! last, now
|
81
81
|
if @system
|
82
82
|
@system.collect @channel do |key, value|
|
83
|
-
|
83
|
+
attributes = FFWD.merge_hashes @attributes, {:what => key, :component => :system}
|
84
84
|
@emitter.metric.emit(
|
85
|
-
:key =>
|
86
|
-
:tags => @tags, :attributes =>
|
85
|
+
:key => @prefix, :value => value,
|
86
|
+
:tags => @tags, :attributes => attributes)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
@reporters.each do |id, reporter|
|
91
91
|
reporter.report! do |d|
|
92
92
|
attributes = FFWD.merge_hashes @attributes, d[:meta]
|
93
|
-
key = "#{@prefix}.#{d[:key]}"
|
94
93
|
@emitter.metric.emit(
|
95
|
-
:key =>
|
94
|
+
:key => @prefix, :value => d[:value],
|
96
95
|
:tags => @tags, :attributes => attributes)
|
97
96
|
end
|
98
97
|
end
|
data/lib/ffwd/tunnel/tcp.rb
CHANGED
@@ -21,8 +21,13 @@ module FFWD::Tunnel
|
|
21
21
|
include FFWD::Lifecycle
|
22
22
|
include FFWD::Reporter
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
report_meta :protocol => :tunnel_tcp
|
25
|
+
|
26
|
+
report_key :received_events, :meta => {:what => :received_events, :unit => :event}
|
27
|
+
report_key :received_metrics, :meta => {:what => :received_metrics, :unit => :metric}
|
28
|
+
|
29
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
30
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
26
31
|
|
27
32
|
attr_reader :log
|
28
33
|
|
data/lib/ffwd/tunnel/udp.rb
CHANGED
@@ -21,8 +21,13 @@ module FFWD::Tunnel
|
|
21
21
|
include FFWD::Lifecycle
|
22
22
|
include FFWD::Reporter
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
report_meta :protocol => :tunnel_udp
|
25
|
+
|
26
|
+
report_key :received_events, :meta => {:what => :received_events, :unit => :event}
|
27
|
+
report_key :received_metrics, :meta => {:what => :received_metrics, :unit => :metric}
|
28
|
+
|
29
|
+
report_key :failed_events, :meta => {:what => :failed_events, :unit => :event}
|
30
|
+
report_key :failed_metrics, :meta => {:what => :failed_metrics, :unit => :metric}
|
26
31
|
|
27
32
|
attr_reader :log
|
28
33
|
|
data/lib/ffwd/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
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-08-
|
12
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -119,6 +119,8 @@ files:
|
|
119
119
|
- lib/ffwd/core/reporter.rb
|
120
120
|
- lib/ffwd/core/emitter.rb
|
121
121
|
- lib/ffwd/handler.rb
|
122
|
+
- lib/ffwd/flushing_output.rb
|
123
|
+
- lib/ffwd/flushing_output_hook.rb
|
122
124
|
- lib/ffwd/version.rb
|
123
125
|
- lib/ffwd/core.rb
|
124
126
|
- lib/ffwd/processor/rate.rb
|