Class: OpenTsdb::DataPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/psc/opentsdb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric, timestamp, value, tags) ⇒ DataPoint

Returns a new instance of DataPoint.



61
62
63
64
65
66
67
68
# File 'lib/psc/opentsdb.rb', line 61

def initialize(metric,timestamp,value,tags)
  @metric = metric
  #DateTime
  @timestamp = timestamp.to_time.to_i
  @value = value
  #Array of Tags
  @tags = tags
end

Instance Attribute Details

#metricObject

Returns the value of attribute metric.



60
61
62
# File 'lib/psc/opentsdb.rb', line 60

def metric
  @metric
end

#tagsObject

Returns the value of attribute tags.



60
61
62
# File 'lib/psc/opentsdb.rb', line 60

def tags
  @tags
end

#timestampObject

Returns the value of attribute timestamp.



60
61
62
# File 'lib/psc/opentsdb.rb', line 60

def timestamp
  @timestamp
end

#valueObject

Returns the value of attribute value.



60
61
62
# File 'lib/psc/opentsdb.rb', line 60

def value
  @value
end

Instance Method Details

#to_hashObject



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/psc/opentsdb.rb', line 70

def to_hash
  h = {}
  h[:metric] = @metric
  h[:timestamp] = @timestamp
  h[:value] = @value
  h[:tags] = {}
  tags.each do |tag|
    h[:tags][tag.tag_name] = tag.tag_value
  end
  h
end