Module: FFWD::Reporter
- Included in:
- FlushingOutput, PluginChannel, Processor::CountProcessor, Processor::HistogramProcessor, Processor::RateProcessor, ProducingClient, TCP::Bind, TCP::FlushingConnect, TCP::PlainConnect, Tunnel::TCP, Tunnel::UDP, UDP::Bind, UDP::Connect
- Defined in:
- lib/ffwd/reporter.rb
Overview
$LICENSE Copyright 2013-2014 Spotify AB. All rights reserved.
The contents of this file are licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build_meta(instance, k) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ffwd/reporter.rb', line 21 def self. instance, k = instance.class. || {} if instance.respond_to?(:reporter_meta) = .merge(instance.send(:reporter_meta)) end return .merge(k[:meta]) end |
.included(mod) ⇒ Object
62 63 64 |
# File 'lib/ffwd/reporter.rb', line 62 def self.included mod mod.extend ClassMethods end |
.map_meta(meta) ⇒ Object
17 18 19 |
# File 'lib/ffwd/reporter.rb', line 17 def self. Hash[.map{|k, v| [k.to_s, v]}] end |
Instance Method Details
#increment(n, c = 1) ⇒ Object
70 71 72 |
# File 'lib/ffwd/reporter.rb', line 70 def increment n, c=1 reporter_data[n] += c end |
#report! ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ffwd/reporter.rb', line 74 def report! self.class.reporter_keys.each do |key| k = key[:key] v = reporter_data[k] reporter_data[k] = 0 = ((@_reporter_meta ||= {})[k] ||= FFWD::Reporter.(self, key)) yield(:key => k, :value => v, :meta => ) end end |
#reporter_data ⇒ Object
66 67 68 |
# File 'lib/ffwd/reporter.rb', line 66 def reporter_data @_reporter_data ||= Hash[self.class.reporter_keys.map{|k| [k[:key], 0]}] end |