Class: Fluent::StatsitePlugin::Histogram
- Inherits:
-
Object
- Object
- Fluent::StatsitePlugin::Histogram
- Defined in:
- lib/fluent/plugin/statsite/histogram.rb
Constant Summary collapse
- FIELD =
%w( min max width )- OPTIONAL_FIELD =
%w(prefix)- FLOATING_FIELD =
%w( min max width )
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(prefix, min, max, width) ⇒ Histogram
constructor
A new instance of Histogram.
- #to_ini ⇒ Object
Constructor Details
#initialize(prefix, min, max, width) ⇒ Histogram
Returns a new instance of Histogram.
18 19 20 21 22 23 24 25 |
# File 'lib/fluent/plugin/statsite/histogram.rb', line 18 def initialize(prefix, min, max, width) @prefix = prefix @min = min @max = max @width = width @section = prefix.nil? ? "default" : prefix end |
Class Method Details
.validate(h) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fluent/plugin/statsite/histogram.rb', line 37 def self.validate(h) if h.class != Hash raise ConfigError, "a type of histogram element must be Hash, but specified as #{h.class}" end FIELD.each do |f| if not h.has_key?(f) raise ConfigError, "histogram element must contain '#{f}'" end end h.keys.each do |k| if not FIELD.member?(k) and not OPTIONAL_FIELD.member?(k) raise ConfigError, "invalid histogram hash key: #{k}" end end FLOATING_FIELD.each do |f| cls = h[f].class if cls != Fixnum and cls != Float raise ConfigError, "#{f} value of histogram must be Fixnum or Float" end end new(h['prefix'], h['min'], h['max'], h['width']) end |
Instance Method Details
#to_ini ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/fluent/plugin/statsite/histogram.rb', line 27 def to_ini "[histogram_\#{@section}]\nprefix=\#{@prefix}\nmin=\#{@min}\nmax=\#{@max}\nwidth=\#{@width}\n INI\nend\n" |