Class: Nark::InfluxDBEmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/nark/influxdb_emitter.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ InfluxDBEmitter

Returns a new instance of InfluxDBEmitter.



5
6
7
# File 'lib/nark/influxdb_emitter.rb', line 5

def initialize(*args)
  @influxdb_client = InfluxDB::Client.new(*args)
end

Instance Method Details

#emit(collection_name, data, timestamp = nil) ⇒ Object



9
10
11
12
13
# File 'lib/nark/influxdb_emitter.rb', line 9

def emit(collection_name, data, timestamp = nil)
  data.merge!(time: timestamp.to_i) if timestamp

  influxdb_client.write_point(collection_name, data)
end

#emit_bulk(data_hash) ⇒ Object



15
16
17
18
19
# File 'lib/nark/influxdb_emitter.rb', line 15

def emit_bulk(data_hash)
  data_hash.each do |collection_name, data|
    influxdb_client.write_point(collection_name, data)
  end
end