opentsdb-consumer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +24 -1
- data/README.md +27 -1
- data/VERSION +1 -1
- data/lib/opentsdb-consumer/errors.rb +3 -0
- data/lib/opentsdb-consumer/query.rb +15 -1
- data/opentsdb-consumer.gemspec +7 -7
- data/spec/opentsdb-consumer/query_spec.rb +13 -2
- data/spec/opentsdb-consumer/result_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 120fe03858090bf837aea765cb2b8b8f56bdee40
|
4
|
+
data.tar.gz: 512c438dd6b56f325829f2b6267c5993d7a55827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5aa02ca4b1d2b906f2307eee3bb2054f79685a443805677d59675bacb5e44533fc46acbfaf2ed676f1e99fd7fcfb409f0f0122e33c31f51e890a91e7d70916
|
7
|
+
data.tar.gz: 0dabff64a9cfc3668df20b7c061724cf801ca83fa2138b7ca064bcbffe96421ba33f46c265fddfb3affff308e694f717338cbb51853e5af390dd120771384b7a
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,10 +7,18 @@ GEM
|
|
7
7
|
columnize (= 0.9.0)
|
8
8
|
coderay (1.1.0)
|
9
9
|
columnize (0.9.0)
|
10
|
+
coveralls (0.8.2)
|
11
|
+
json (~> 1.8)
|
12
|
+
rest-client (>= 1.6.8, < 2)
|
13
|
+
simplecov (~> 0.10.0)
|
14
|
+
term-ansicolor (~> 1.3)
|
15
|
+
thor (~> 0.19.1)
|
10
16
|
descendants_tracker (0.0.4)
|
11
17
|
thread_safe (~> 0.3, >= 0.3.1)
|
12
18
|
diff-lcs (1.2.5)
|
13
19
|
docile (1.1.5)
|
20
|
+
domain_name (0.5.24)
|
21
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
22
|
excon (0.45.4)
|
15
23
|
faraday (0.9.1)
|
16
24
|
multipart-post (>= 1.2, < 3)
|
@@ -25,6 +33,8 @@ GEM
|
|
25
33
|
oauth2
|
26
34
|
hashie (3.4.2)
|
27
35
|
highline (1.7.3)
|
36
|
+
http-cookie (1.0.2)
|
37
|
+
domain_name (~> 0.5)
|
28
38
|
jeweler (2.0.1)
|
29
39
|
builder
|
30
40
|
bundler (>= 1.0)
|
@@ -37,10 +47,12 @@ GEM
|
|
37
47
|
json (1.8.3)
|
38
48
|
jwt (1.5.1)
|
39
49
|
method_source (0.8.2)
|
50
|
+
mime-types (2.6.1)
|
40
51
|
mini_portile (0.6.2)
|
41
52
|
multi_json (1.11.2)
|
42
53
|
multi_xml (0.5.5)
|
43
54
|
multipart-post (2.0.0)
|
55
|
+
netrc (0.10.3)
|
44
56
|
nokogiri (1.6.6.2)
|
45
57
|
mini_portile (~> 0.6.0)
|
46
58
|
oauth2 (1.0.0)
|
@@ -57,6 +69,10 @@ GEM
|
|
57
69
|
rake (10.4.2)
|
58
70
|
rdoc (3.12.2)
|
59
71
|
json (~> 1.4)
|
72
|
+
rest-client (1.8.0)
|
73
|
+
http-cookie (>= 1.0.2, < 2.0)
|
74
|
+
mime-types (>= 1.16, < 3.0)
|
75
|
+
netrc (~> 0.7)
|
60
76
|
rspec (3.3.0)
|
61
77
|
rspec-core (~> 3.3.0)
|
62
78
|
rspec-expectations (~> 3.3.0)
|
@@ -76,7 +92,14 @@ GEM
|
|
76
92
|
simplecov-html (~> 0.10.0)
|
77
93
|
simplecov-html (0.10.0)
|
78
94
|
slop (3.6.0)
|
95
|
+
term-ansicolor (1.3.2)
|
96
|
+
tins (~> 1.0)
|
97
|
+
thor (0.19.1)
|
79
98
|
thread_safe (0.3.5)
|
99
|
+
tins (1.6.0)
|
100
|
+
unf (0.1.4)
|
101
|
+
unf_ext
|
102
|
+
unf_ext (0.0.7.1)
|
80
103
|
|
81
104
|
PLATFORMS
|
82
105
|
ruby
|
@@ -84,12 +107,12 @@ PLATFORMS
|
|
84
107
|
DEPENDENCIES
|
85
108
|
bundler (~> 1.0)
|
86
109
|
byebug
|
110
|
+
coveralls
|
87
111
|
excon (~> 0.45.0)
|
88
112
|
jeweler (~> 2.0.1)
|
89
113
|
pry
|
90
114
|
rdoc (~> 3.12)
|
91
115
|
rspec (~> 3.3.0)
|
92
|
-
simplecov
|
93
116
|
|
94
117
|
BUNDLED WITH
|
95
118
|
1.10.6
|
data/README.md
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
-
opentsdb-consumer
|
1
|
+
opentsdb-consumer
|
2
2
|
=================
|
3
3
|
|
4
|
+
[![Build Status](https://travis-ci.org/ninech/opentsdb-consumer.svg)](https://travis-ci.org/ninech/opentsdb-consumer)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/ninech/opentsdb-consumer/badge.svg?branch=master&service=github)](https://coveralls.io/github/ninech/opentsdb-consumer?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/ninech/opentsdb-consumer/badges/gpa.svg)](https://codeclimate.com/github/ninech/opentsdb-consumer)
|
7
|
+
|
4
8
|
Client library to fetch metrics from OpenTSDB.
|
5
9
|
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add it to your Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'opentsdb-consumer'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
client = OpenTSDBConsumer::Client.new host: 'metrics.yourdomain.com', port: 4242
|
22
|
+
metric = OpenTSDBConsumer::Metric.new name: 'my.metric', rate: true, aggregator: 'avg'
|
23
|
+
OpenTSDBConsumer::Query.new(metric, client).run start: '24h-ago'
|
24
|
+
```
|
25
|
+
|
6
26
|
## Contributing to opentsdb-consumer
|
7
27
|
|
8
28
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -13,6 +33,12 @@ Client library to fetch metrics from OpenTSDB.
|
|
13
33
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
14
34
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
15
35
|
|
36
|
+
To test and debug you can use the debug script:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
bin/opentsdb-consumer server.domain.com my.metric
|
40
|
+
```
|
41
|
+
|
16
42
|
## Copyright
|
17
43
|
|
18
44
|
Copyright (c) 2015 Nine Internet Solutions AG. See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -14,7 +14,21 @@ module OpenTSDBConsumer
|
|
14
14
|
parsed_body = JSON.parse(response.body)
|
15
15
|
return OpenTSDBConsumer::Result.build(parsed_body) if response.status < 400
|
16
16
|
|
17
|
-
|
17
|
+
response_message = parsed_body['error']['message']
|
18
|
+
fail error_for_response(response_message), response_message
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def error_for_response(response_message)
|
24
|
+
case response_message
|
25
|
+
when /^No such name for 'tagv'/
|
26
|
+
InvalidTag
|
27
|
+
when /^No such name for 'metrics'/
|
28
|
+
InvalidMetric
|
29
|
+
else
|
30
|
+
QueryError
|
31
|
+
end
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
data/opentsdb-consumer.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: opentsdb-consumer 0.1.
|
5
|
+
# stub: opentsdb-consumer 0.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "opentsdb-consumer"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Philippe H\u{e4}ssig"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-11-10"
|
15
15
|
s.description = "Client library to consume metrics from OpenTSDB"
|
16
16
|
s.email = "phil@nine.ch"
|
17
17
|
s.executables = ["opentsdb-consumer"]
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
]
|
46
46
|
s.homepage = "http://github.com/ninech/opentsdb-consumer"
|
47
47
|
s.licenses = ["MIT"]
|
48
|
-
s.rubygems_version = "2.4.5"
|
48
|
+
s.rubygems_version = "2.4.5.1"
|
49
49
|
s.summary = "Client library to consume metrics from OpenTSDB"
|
50
50
|
|
51
51
|
if s.respond_to? :specification_version then
|
@@ -57,18 +57,18 @@ Gem::Specification.new do |s|
|
|
57
57
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
58
58
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
59
59
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
60
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
61
60
|
s.add_development_dependency(%q<byebug>, [">= 0"])
|
62
61
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
63
63
|
else
|
64
64
|
s.add_dependency(%q<excon>, ["~> 0.45.0"])
|
65
65
|
s.add_dependency(%q<rspec>, ["~> 3.3.0"])
|
66
66
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
67
67
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
68
68
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
69
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
70
69
|
s.add_dependency(%q<byebug>, [">= 0"])
|
71
70
|
s.add_dependency(%q<pry>, [">= 0"])
|
71
|
+
s.add_dependency(%q<coveralls>, [">= 0"])
|
72
72
|
end
|
73
73
|
else
|
74
74
|
s.add_dependency(%q<excon>, ["~> 0.45.0"])
|
@@ -76,9 +76,9 @@ Gem::Specification.new do |s|
|
|
76
76
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
77
77
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
78
78
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
79
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
80
79
|
s.add_dependency(%q<byebug>, [">= 0"])
|
81
80
|
s.add_dependency(%q<pry>, [">= 0"])
|
81
|
+
s.add_dependency(%q<coveralls>, [">= 0"])
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -36,8 +36,19 @@ RSpec.describe OpenTSDBConsumer::Query do
|
|
36
36
|
%({"error":{"code":400,"message":"No such name for 'metrics': '#{metric.name}'"}})
|
37
37
|
end
|
38
38
|
|
39
|
-
it 'raises
|
40
|
-
expect { query.run }.to raise_exception OpenTSDBConsumer::
|
39
|
+
it 'raises the appropriate error' do
|
40
|
+
expect { query.run }.to raise_exception OpenTSDBConsumer::InvalidMetric
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'invalid tag' do
|
45
|
+
let(:status) { 400 }
|
46
|
+
let(:response_body) do
|
47
|
+
%({"error":{"code":400,"message":"No such name for 'tagv': 'pony-01'"}})
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'raises the appropriate error' do
|
51
|
+
expect { query.run }.to raise_exception OpenTSDBConsumer::InvalidTag
|
41
52
|
end
|
42
53
|
end
|
43
54
|
end
|
@@ -7,12 +7,12 @@ RSpec.describe OpenTSDBConsumer::Result do
|
|
7
7
|
result = described_class.new 'metric' => 'my.metric',
|
8
8
|
'tags' => {},
|
9
9
|
'aggregateTags' => [],
|
10
|
-
'dps' => [{ '1'
|
10
|
+
'dps' => [{ '1' => 2 }]
|
11
11
|
|
12
12
|
expect(result.metric_name).to eq 'my.metric'
|
13
13
|
expect(result.tags).to eq({})
|
14
14
|
expect(result.aggregate_tags).to eq []
|
15
|
-
expect(result.datapoints).to eq [{ '1'
|
15
|
+
expect(result.datapoints).to eq [{ '1' => 2 }]
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
|
-
require 'simplecov'
|
2
1
|
|
3
|
-
module SimpleCov::Configuration
|
4
|
-
def clean_filters
|
5
|
-
@filters = []
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.configure do
|
10
|
-
clean_filters
|
11
|
-
load_profile 'root_filter'
|
12
|
-
end
|
13
|
-
|
14
|
-
ENV['COVERAGE'] && SimpleCov.start do
|
15
|
-
end
|
16
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
18
4
|
|
19
5
|
require 'rspec'
|
20
6
|
require 'opentsdb-consumer'
|
21
7
|
|
8
|
+
require 'coveralls'
|
9
|
+
Coveralls.wear!
|
10
|
+
|
22
11
|
# Requires supporting files with custom matchers and macros, etc,
|
23
12
|
# in ./support/ and its subdirectories.
|
24
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentsdb-consumer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philippe Hässig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.0.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: pry
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: coveralls
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.4.5
|
176
|
+
rubygems_version: 2.4.5.1
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Client library to consume metrics from OpenTSDB
|