influxer 1.1.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +102 -0
- data/{MIT-LICENSE → LICENSE.txt} +1 -1
- data/README.md +106 -47
- data/lib/influxer.rb +10 -9
- data/lib/influxer/client.rb +2 -2
- data/lib/influxer/config.rb +19 -6
- data/lib/influxer/engine.rb +1 -1
- data/lib/influxer/metrics/active_model3/model.rb +2 -4
- data/lib/influxer/metrics/metrics.rb +10 -13
- data/lib/influxer/metrics/quoting/timestamp.rb +23 -11
- data/lib/influxer/metrics/relation.rb +33 -17
- data/lib/influxer/metrics/relation/calculations.rb +1 -1
- data/lib/influxer/metrics/relation/time_query.rb +15 -13
- data/lib/influxer/metrics/relation/where_clause.rb +15 -7
- data/lib/influxer/metrics/scoping.rb +4 -4
- data/lib/influxer/metrics/scoping/current_scope.rb +2 -1
- data/lib/influxer/metrics/scoping/default.rb +1 -1
- data/lib/influxer/metrics/scoping/named.rb +2 -1
- data/lib/influxer/model.rb +4 -9
- data/lib/influxer/rails/client.rb +6 -6
- data/lib/influxer/version.rb +1 -1
- metadata +32 -97
- data/.gitignore +0 -37
- data/.rspec +0 -2
- data/.rubocop.yml +0 -77
- data/.travis.yml +0 -10
- data/Changelog.md +0 -116
- data/Gemfile +0 -10
- data/Rakefile +0 -13
- data/gemfiles/rails32.gemfile +0 -7
- data/gemfiles/rails42.gemfile +0 -7
- data/gemfiles/rails5.gemfile +0 -7
- data/influxer.gemspec +0 -33
- data/spec/cases/points_spec.rb +0 -36
- data/spec/cases/write_points_spec.rb +0 -85
- data/spec/client_spec.rb +0 -46
- data/spec/fixtures/empty_result.json +0 -21
- data/spec/fixtures/single_series.json +0 -29
- data/spec/metrics/metrics_spec.rb +0 -283
- data/spec/metrics/relation_spec.rb +0 -485
- data/spec/metrics/scoping_spec.rb +0 -66
- data/spec/model/user_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -64
- data/spec/support/metrics/action_metrics.rb +0 -5
- data/spec/support/metrics/custom_metrics.rb +0 -6
- data/spec/support/metrics/dummy_metrics.rb +0 -12
- data/spec/support/metrics/user_metrics.rb +0 -6
- data/spec/support/metrics/visits_metrics.rb +0 -8
- data/spec/support/shared_contexts/shared_query.rb +0 -16
- data/spec/support/user.rb +0 -16
data/.gitignore
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Numerous always-ignore extensions
|
2
|
-
*.diff
|
3
|
-
*.err
|
4
|
-
*.orig
|
5
|
-
*.log
|
6
|
-
*.rej
|
7
|
-
*.swo
|
8
|
-
*.swp
|
9
|
-
*.vi
|
10
|
-
*~
|
11
|
-
*.sass-cache
|
12
|
-
*.iml
|
13
|
-
.idea/
|
14
|
-
|
15
|
-
# Sublime
|
16
|
-
*.sublime-project
|
17
|
-
*.sublime-workspace
|
18
|
-
|
19
|
-
# OS or Editor folders
|
20
|
-
.DS_Store
|
21
|
-
.cache
|
22
|
-
.project
|
23
|
-
.settings
|
24
|
-
.tmproj
|
25
|
-
Thumbs.db
|
26
|
-
|
27
|
-
.bundle/
|
28
|
-
log/*.log
|
29
|
-
pkg/
|
30
|
-
spec/dummy/db/*.sqlite3
|
31
|
-
spec/dummy/db/*.sqlite3-journal
|
32
|
-
spec/dummy/tmp/
|
33
|
-
tmp/
|
34
|
-
|
35
|
-
Gemfile.lock
|
36
|
-
Gemfile.local
|
37
|
-
*.gem
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
# Include gemspec and Rakefile
|
3
|
-
Include:
|
4
|
-
- 'lib/**/*.rb'
|
5
|
-
- 'lib/**/*.rake'
|
6
|
-
- 'spec/**/*.rb'
|
7
|
-
Exclude:
|
8
|
-
- 'bin/**/*'
|
9
|
-
- 'spec/dummy/**/*'
|
10
|
-
- 'vendor/**/*'
|
11
|
-
- 'gemfiles/vendor/**/*'
|
12
|
-
- Gemfile
|
13
|
-
- Rakefile
|
14
|
-
DisplayCopNames: true
|
15
|
-
StyleGuideCopsOnly: false
|
16
|
-
TargetRubyVersion: 2.3
|
17
|
-
|
18
|
-
Rails:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/SymbolArray:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
Style/SafeNavigation:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Naming/AccessorMethodName:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Style/TrivialAccessors:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Style/Documentation:
|
34
|
-
Exclude:
|
35
|
-
- 'spec/**/*.rb'
|
36
|
-
|
37
|
-
Style/StringLiterals:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Style/DateTime:
|
41
|
-
Exclude:
|
42
|
-
- 'spec/**/*.rb'
|
43
|
-
|
44
|
-
Naming/SpaceInsideStringInterpolation:
|
45
|
-
EnforcedStyle: no_space
|
46
|
-
|
47
|
-
Style/BlockDelimiters:
|
48
|
-
Exclude:
|
49
|
-
- 'spec/**/*.rb'
|
50
|
-
|
51
|
-
Lint/MissingCopEnableDirective:
|
52
|
-
Enabled: false
|
53
|
-
|
54
|
-
Lint/AmbiguousRegexpLiteral:
|
55
|
-
Enabled: false
|
56
|
-
|
57
|
-
Metrics/BlockLength:
|
58
|
-
Exclude:
|
59
|
-
- 'spec/**/*.rb'
|
60
|
-
|
61
|
-
Metrics/MethodLength:
|
62
|
-
Exclude:
|
63
|
-
- 'spec/**/*.rb'
|
64
|
-
|
65
|
-
Metrics/LineLength:
|
66
|
-
Max: 100
|
67
|
-
Exclude:
|
68
|
-
- 'spec/**/*.rb'
|
69
|
-
|
70
|
-
Rails/Date:
|
71
|
-
Enabled: false
|
72
|
-
|
73
|
-
Rails/TimeZone:
|
74
|
-
Enabled: false
|
75
|
-
|
76
|
-
Gemspec/OrderedDependencies:
|
77
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/Changelog.md
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
# Change log
|
2
|
-
|
3
|
-
## master
|
4
|
-
|
5
|
-
## 1.1.5
|
6
|
-
|
7
|
-
- [Fixes [#37](https://github.com/palkan/influxer/issues/37)] Timestamp ranges are quoted again. ([@jklimke][])
|
8
|
-
|
9
|
-
## 1.1.4
|
10
|
-
|
11
|
-
- [Fixes [#35](https://github.com/palkan/influxer/issues/35)] Support time duration suffix and handle `'s'` and `'ms'` precisions. ([@palkan][])
|
12
|
-
|
13
|
-
[PR](https://github.com/palkan/influxer/pull/36)
|
14
|
-
|
15
|
-
**BREAKING:** `Time`-like value are only typecasted for `time` key.
|
16
|
-
|
17
|
-
## 1.1.2
|
18
|
-
|
19
|
-
- Support exclusive ranges as `where` arguments. ([@MPursche][])
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
# range including the end
|
23
|
-
where(a: 1..4)
|
24
|
-
#=> ... WHERE a >= 1 AND a <= 4
|
25
|
-
|
26
|
-
#range excluding the end
|
27
|
-
where(a: 1...4)
|
28
|
-
#=> ... WHERE a >= 1 AND a < 4
|
29
|
-
```
|
30
|
-
|
31
|
-
## 1.1.1
|
32
|
-
|
33
|
-
- [Fixes [#31](https://github.com/palkan/influxer/issues/31)] Fix bug with empty arrays in `where` clause
|
34
|
-
|
35
|
-
- Introduce `Relation#none` method
|
36
|
-
|
37
|
-
## 1.1.0
|
38
|
-
|
39
|
-
### Features
|
40
|
-
|
41
|
-
- Add ability to specify per-metrics retention-policy, precision and database
|
42
|
-
|
43
|
-
Now you can override default configuration for a specific metrics class:
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
class CustomMetrics < Influxer::Metrics
|
47
|
-
set_database "custom_db"
|
48
|
-
set_retention_policy :yearly
|
49
|
-
set_precision "ms"
|
50
|
-
end
|
51
|
-
```
|
52
|
-
|
53
|
-
### Fixes
|
54
|
-
|
55
|
-
- [Fixes [#30](https://github.com/palkan/influxer/issues/30)] Fix writing points with custom retention policy
|
56
|
-
|
57
|
-
### Misc
|
58
|
-
|
59
|
-
- Update Rubocop configuration and add Rubocop Rake task to defaults
|
60
|
-
|
61
|
-
## 1.0.1
|
62
|
-
|
63
|
-
- Fix missing `#delegate` in ActiveRecord 3.2
|
64
|
-
|
65
|
-
## 0.5.4
|
66
|
-
- Add `set_retention_policy` method
|
67
|
-
|
68
|
-
## 0.5.3
|
69
|
-
- Fix `where.not` with ranges typo
|
70
|
-
|
71
|
-
## 0.5.2
|
72
|
-
- Fix bug with query logging
|
73
|
-
|
74
|
-
## 0.5.1
|
75
|
-
- Fix whitespace around operators
|
76
|
-
- Add `Relation#from` method to redefine series
|
77
|
-
- Handle nil values for tags in #where clause
|
78
|
-
|
79
|
-
## 0.5.0
|
80
|
-
- Update `timestamp` support
|
81
|
-
- Add `epoch` method
|
82
|
-
|
83
|
-
## 0.4.0
|
84
|
-
- Rename default `time` attribute to `timestamp`
|
85
|
-
|
86
|
-
## 0.2.3
|
87
|
-
- Parse fanout queries points to handle _fanouted_ values
|
88
|
-
- Add Rubocop config and cleanup code style
|
89
|
-
|
90
|
-
## 0.1.1
|
91
|
-
- Add [anyway_config](https://github.com/palkan/anyway_config)
|
92
|
-
- Add `empty?` method
|
93
|
-
|
94
|
-
## 0.1.0
|
95
|
-
- Add logs
|
96
|
-
- Add `foreign_key` param to `has_metrics` options
|
97
|
-
|
98
|
-
## 0.1.0-rc
|
99
|
-
- Fix `Relation#to_a` (now returns array of points correctrly)
|
100
|
-
- Fix fanout queries with array args (now use `merge(Regexp)`)
|
101
|
-
|
102
|
-
## 0.1.0-alpha
|
103
|
-
- Add `time` method to Relation to group by time with constants (`:hour`, `:day`, etc) and fill support
|
104
|
-
- Series names now properly quoted with double-quotes
|
105
|
-
- Using regexps, ranges and arrays within `where` clause
|
106
|
-
- `where.not(...)` support
|
107
|
-
- Add `past` and `since` methods
|
108
|
-
- Add `merge` method and support for regexp series
|
109
|
-
- Add `delete_all` support
|
110
|
-
- Add cache support (using `Rails.cache`)
|
111
|
-
- Scopes (default and named)
|
112
|
-
- Support for fanout series
|
113
|
-
|
114
|
-
[@palkan]: https://github.com/palkan
|
115
|
-
[@MPursche]: https://github.com/MPursche
|
116
|
-
[@jklimke]: https://github.com/jklimke
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/gemfiles/rails32.gemfile
DELETED
data/gemfiles/rails42.gemfile
DELETED
data/gemfiles/rails5.gemfile
DELETED
data/influxer.gemspec
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
4
|
-
|
5
|
-
require "influxer/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "influxer"
|
9
|
-
s.version = Influxer::VERSION
|
10
|
-
s.authors = ["Vlad Dem"]
|
11
|
-
s.email = ["dementiev.vm@gmail.com"]
|
12
|
-
s.homepage = "http://github.com/palkan/influxer"
|
13
|
-
s.summary = "InfluxDB for Rails"
|
14
|
-
s.description = "InfluxDB the Rails way"
|
15
|
-
s.license = "MIT"
|
16
|
-
|
17
|
-
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
|
20
|
-
s.add_dependency "activemodel", '>= 3.2.0'
|
21
|
-
s.add_dependency "influxdb", "~> 0.3"
|
22
|
-
s.add_dependency "anyway_config", "~> 1.0"
|
23
|
-
|
24
|
-
s.add_development_dependency "timecop"
|
25
|
-
s.add_development_dependency "simplecov", ">= 0.3.8"
|
26
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
27
|
-
s.add_development_dependency 'sqlite3'
|
28
|
-
s.add_development_dependency 'activerecord', '>= 3.2.0'
|
29
|
-
s.add_development_dependency 'pry-byebug'
|
30
|
-
s.add_development_dependency "rspec", ">= 3.1.0"
|
31
|
-
s.add_development_dependency "webmock", "~> 2.1"
|
32
|
-
s.add_development_dependency "rubocop", "~> 0.52"
|
33
|
-
end
|
data/spec/cases/points_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe DummyMetrics do
|
6
|
-
before do
|
7
|
-
stub_request(:get, "http://localhost:8086/query")
|
8
|
-
.with(
|
9
|
-
query: { q: 'select * from "dummy"', u: "root", p: "root", precision: 'ns', db: 'db' }
|
10
|
-
)
|
11
|
-
.to_return(body: fixture_file)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "single_series" do
|
15
|
-
let(:fixture_file) { File.read('./spec/fixtures/single_series.json') }
|
16
|
-
|
17
|
-
context "default format (values merged with tags)" do
|
18
|
-
subject { described_class.all.to_a }
|
19
|
-
|
20
|
-
it "returns array of hashes" do
|
21
|
-
expect(subject.first).to include("host" => "server01", "region" => "us-west", "value" => 0.64)
|
22
|
-
expect(subject.second).to include("host" => "server01", "region" => "us-west", "value" => 0.93)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "empty result" do
|
28
|
-
let(:fixture_file) { File.read('./spec/fixtures/empty_result.json') }
|
29
|
-
|
30
|
-
subject { described_class.all.to_a }
|
31
|
-
|
32
|
-
it "returns empty array" do
|
33
|
-
expect(subject).to eq []
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe "Write points" do
|
6
|
-
before do
|
7
|
-
stub_request(:post, /write/)
|
8
|
-
.to_return(
|
9
|
-
status: 204
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:metrics_class) do
|
14
|
-
Class.new(Influxer::Metrics) do
|
15
|
-
set_series :test
|
16
|
-
|
17
|
-
tags :user_id
|
18
|
-
|
19
|
-
attributes :val
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
let(:point) { 'test,user_id=1 val="2"' }
|
24
|
-
|
25
|
-
subject { metrics_class.write! user_id: 1, val: '2' }
|
26
|
-
|
27
|
-
it "calls HTTP with correct params" do
|
28
|
-
subject
|
29
|
-
expect(
|
30
|
-
a_request(:post, "http://localhost:8086/write")
|
31
|
-
.with(
|
32
|
-
query: { u: "root", p: "root", precision: 'ns', db: 'db' },
|
33
|
-
body: point
|
34
|
-
)
|
35
|
-
).to have_been_made
|
36
|
-
end
|
37
|
-
|
38
|
-
context "with retention policy" do
|
39
|
-
it "calls HTTP with correct params" do
|
40
|
-
metrics_class.set_retention_policy 'yearly'
|
41
|
-
|
42
|
-
subject
|
43
|
-
|
44
|
-
expect(
|
45
|
-
a_request(:post, "http://localhost:8086/write")
|
46
|
-
.with(
|
47
|
-
query: { u: "root", p: "root", precision: 'ns', db: 'db', rp: 'yearly' },
|
48
|
-
body: point
|
49
|
-
)
|
50
|
-
).to have_been_made
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "with custom db" do
|
55
|
-
it "calls HTTP with correct params" do
|
56
|
-
metrics_class.set_database 'another_db'
|
57
|
-
|
58
|
-
subject
|
59
|
-
|
60
|
-
expect(
|
61
|
-
a_request(:post, "http://localhost:8086/write")
|
62
|
-
.with(
|
63
|
-
query: { u: "root", p: "root", precision: 'ns', db: 'another_db' },
|
64
|
-
body: point
|
65
|
-
)
|
66
|
-
).to have_been_made
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "with custom db" do
|
71
|
-
it "calls HTTP with correct params" do
|
72
|
-
metrics_class.set_precision 'ms'
|
73
|
-
|
74
|
-
subject
|
75
|
-
|
76
|
-
expect(
|
77
|
-
a_request(:post, "http://localhost:8086/write")
|
78
|
-
.with(
|
79
|
-
query: { u: "root", p: "root", precision: 'ms', db: 'db' },
|
80
|
-
body: point
|
81
|
-
)
|
82
|
-
).to have_been_made
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|