Skip to content

Commit

Permalink
Support all InfluxDB time resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
vassilevsky committed May 3, 2019
1 parent 69270a7 commit 167b6f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Sidekiq-InfluxDB Changelog

## 1.2.0 (2019-05-03)

* Support all InfluxDB time resolutions (added `ns`, `m`, `h`)

## 1.1.0 (2018-09-03)

* ActiveJob support added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ When you deploy this code, you will start getting the following series in your I

Tags (repetitive, indexed data — for filtering and grouping by):

* `time` — Standard InfluxDB timestamp. Precision of the supplied client is respected. Only `s`, `ms`, and `u` precisions are supported.
* `time` — Standard InfluxDB timestamp. Precision of the supplied client is respected.
* `queue` — Queue name.
* `class` — Job class name. Classes from `except:` keyword argument are skipped (no data is sent to InfluxDB).
* `event` — What happened to the job at the specified `time`: `start`, `finish`, or `error`. If you initialize the middleware with `start_events: false`, there will be no `start` events.
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq/influxdb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Sidekiq
module InfluxDB
VERSION = "1.1.0"
VERSION = "1.2.0"
end
end
7 changes: 5 additions & 2 deletions lib/sidekiq/middleware/server/influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ def precision
def in_correct_precision(t)
case precision
# In order of probability in real-world setups
when 'ms' then (t * 1000).to_i
when 'ms' then (t * 1_000).to_i
when 's' then t.to_i
when 'u' then (t * 1000000).to_i
when 'u' then (t * 1_000_000).to_i
when 'ns' then (t * 1_000_000_000).to_i
when 'm' then (t / 60).to_i
when 'h' then (t / 60 / 60).to_i
end
end

Expand Down

0 comments on commit 167b6f8

Please sign in to comment.