Sha256: 9c436634571f157a3c9dc7e09c29825f9278cb4b2ca33ba87ef1346263055695

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

require 'hallmonitor/monitored'
module Hallmonitor
  # The event class is a single-fire event, it most often
  # represents a single, countable metric.
  class Event
    include Hallmonitor::Monitored

    attr_accessor :name, :time, :count, :tags

    # Builds a new event
    # @param name [String] the name of this event
    # @param count [Number] the count of this even, defaults to 1
    def initialize(name, count=1, tags: {})
      @name = name
      @time = Time.now
      @count = count
      @tags = tags
    end

    def to_json(*a)
      {
        name: @name,
        time: @time,
        count: @count,
        tags: @tags
      }.to_json(*a)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hallmonitor-1.1.0 lib/hallmonitor/event.rb