Skip to content

Commit

Permalink
Do not run InfluxDB backend subscriber in background
Browse files Browse the repository at this point in the history
It is not necessary as the influxdb gem already does this. This will also fix a flaky spec.
  • Loading branch information
ChrisBr committed Dec 10, 2018
1 parent 561a812 commit 98a7b0c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/api/lib/influxdb_obs/obs/middleware/backend_subscriber.rb
Expand Up @@ -12,14 +12,12 @@ def initialize(series_name, logger = Logger.new(STDOUT))
def call(_name, _started, finished, _unique_id, data)
return unless enabled?

execute_in_background do
InfluxDB::Rails.client.write_point(series_name,
tags: tags(data),
values: values(data[:runtime]),
timestamp: InfluxDB::Rails.convert_timestamp(finished.utc))
rescue StandardError => e
logger.info "[InfluxDB Backend Subscriber]: #{e.message}"
end
InfluxDB::Rails.client.write_point(series_name,
tags: tags(data),
values: values(data[:runtime]),
timestamp: InfluxDB::Rails.convert_timestamp(finished.utc))
rescue StandardError => e
logger.info "[InfluxDB Backend Subscriber]: #{e.message}"
end

private
Expand All @@ -30,12 +28,6 @@ def enabled?
series_name.present?
end

def execute_in_background
Thread.new do
yield
end
end

def values(runtime)
{ value: (runtime || 0) * 1000 }
end
Expand Down

0 comments on commit 98a7b0c

Please sign in to comment.