Sha256: ab78b880a378350855cc8cff868b500f1a49ececa71eb786c83b80c2077f1d40

Contents?: true

Size: 991 Bytes

Versions: 29

Compression:

Stored size: 991 Bytes

Contents

module Kurchatov
  module Riemann
    class Event
      include Beefcake::Message
      optional :time, :int64, 1
      optional :state, :string, 2
      required :service, :string, 3
      required :host, :string, 4
      optional :description, :string, 5
      repeated :tags, :string, 7
      optional :ttl, :float, 8
      optional :metric_sint64, :sint64, 13
      optional :metric_d, :double, 14
      optional :metric_f, :float, 15

      def initialize(hash = nil)
        if hash
          super(hash)
          self.metric = hash[:metric] if hash[:metric]
        else
          super
        end
        @time ||= Time.now.to_i
      end

      def metric
        metric_d || metric_sint64 || metric_f
      end
      
      def metric=(m)
        if Integer === m and (-(2**63)...2**63) === m
          self.metric_sint64 = m
          self.metric_f = m.to_f
        else
          self.metric_d = m.to_f
          self.metric_f = m.to_f
        end
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
kurchatov-0.2.6 lib/kurchatov/riemann/event.rb
kurchatov-0.2.5 lib/kurchatov/riemann/event.rb
kurchatov-0.2.4 lib/kurchatov/riemann/event.rb
kurchatov-0.2.3 lib/kurchatov/riemann/event.rb
kurchatov-0.2.2 lib/kurchatov/riemann/event.rb
kurchatov-0.2.1 lib/kurchatov/riemann/event.rb
kurchatov-0.2.0 lib/kurchatov/riemann/event.rb
kurchatov-0.1.8 lib/kurchatov/riemann/event.rb
kurchatov-0.1.7 lib/kurchatov/riemann/event.rb
kurchatov-0.1.6 lib/kurchatov/riemann/event.rb
kurchatov-0.1.5 lib/kurchatov/riemann/event.rb
kurchatov-0.1.4 lib/kurchatov/riemann/event.rb
kurchatov-0.1.3 lib/kurchatov/riemann/event.rb
kurchatov-0.1.2 lib/kurchatov/riemann/event.rb
kurchatov-0.1.1 lib/kurchatov/riemann/event.rb
kurchatov-0.1.0 lib/kurchatov/riemann/event.rb
kurchatov-0.0.9 lib/kurchatov/riemann/event.rb
kurchatov-0.0.8.pre.3 lib/kurchatov/riemann/event.rb
kurchatov-0.0.7.pre.4 lib/kurchatov/riemann/event.rb
kurchatov-0.0.8.pre.2 lib/kurchatov/riemann/event.rb