Skip to content

Commit

Permalink
Use InfluxDB time_precision configuration
Browse files Browse the repository at this point in the history
otherwise it would write other data points than
the influxdb-rails gem.
  • Loading branch information
ChrisBr committed Dec 11, 2018
1 parent 3473cb7 commit a21ea6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call(_name, _started, finished, _unique_id, data)
InfluxDB::Rails.client.write_point(series_name,
tags: tags(data),
values: values(data[:runtime]),
timestamp: InfluxDB.convert_timestamp(finished.utc))
timestamp: timestamp(finished))
rescue StandardError => e
logger.info "[InfluxDB Backend Subscriber]: #{e.message}"
end
Expand All @@ -24,6 +24,10 @@ def call(_name, _started, finished, _unique_id, data)

attr_reader :series_name, :logger

def timestamp(time)
InfluxDB.convert_timestamp(time, InfluxDB::Rails.configuration.time_precision)
end

def enabled?
CONFIG['influxdb_hosts'].present?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
controller_location: 'UsersController#index',
backend_location: 'Cloud#upload'
},
timestamp: 1_517_567_370
timestamp: 1_517_567_370_000
}
end

before do
stub_const('CONFIG', CONFIG.merge('influxdb_hosts' => ['localhost']))
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:time_precision).and_return('ms')
end

it 'writes to InfluxDB' do
Expand Down

0 comments on commit a21ea6b

Please sign in to comment.