opentsdb-consumer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/opentsdb-consumer/query.rb +5 -0
- data/lib/opentsdb-consumer/result.rb +5 -0
- data/opentsdb-consumer.gemspec +3 -3
- data/spec/opentsdb-consumer/query_spec.rb +11 -0
- data/spec/opentsdb-consumer/result_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3946790fd8040a154653d58d3729179da5300548
|
4
|
+
data.tar.gz: efb1a9798819da7e28133d7d95f82227a36cad36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cccd3f3fa6cdb099815724d4640301c21cc2e9e623c89274b6c18ff71095dc2a3ee387f90e92af030935c4682b5b19c6f2038ae1bd6a0831d6c6e4db8f50f17
|
7
|
+
data.tar.gz: 60d00471c835408a5cf13b3f3b3fbc45c135614801d12abcb664f7aa986dbac5df8cd9e7d21ef7f86b5d90bfc1531e88f85417c4eadce0f844388ec308da9de8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -13,5 +13,10 @@ module OpenTSDBConsumer
|
|
13
13
|
results = response.map { |h| new(h) }
|
14
14
|
results.length > 1 ? results : results.first
|
15
15
|
end
|
16
|
+
|
17
|
+
def latest_value
|
18
|
+
datapoint = datapoints.max_by { |timestamp, _| timestamp }
|
19
|
+
datapoint.last if datapoint
|
20
|
+
end
|
16
21
|
end
|
17
22
|
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.
|
5
|
+
# stub: opentsdb-consumer 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "opentsdb-consumer"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
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-12-07"
|
15
15
|
s.description = "Client library to consume metrics from OpenTSDB"
|
16
16
|
s.email = "phil@nine.ch"
|
17
17
|
s.executables = ["opentsdb-consumer"]
|
@@ -55,4 +55,15 @@ RSpec.describe OpenTSDBConsumer::Query do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
describe '#latest_value' do
|
60
|
+
let(:response_body) do
|
61
|
+
%([{"metric":"yolo","tags":{"node":"n1"},"dps":{"1448965805":1.95,"1448965864":2.21}}])
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'returns the latest value in the series' do
|
65
|
+
expect(client).to receive(:post).and_return(mock_response)
|
66
|
+
expect(query.latest_value).to eq(2.21)
|
67
|
+
end
|
68
|
+
end
|
58
69
|
end
|
@@ -30,4 +30,16 @@ RSpec.describe OpenTSDBConsumer::Result do
|
|
30
30
|
expect(results.last).to be_a OpenTSDBConsumer::Result
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
describe '#latest_value' do
|
35
|
+
it 'returns to newest value in the series' do
|
36
|
+
result = OpenTSDBConsumer::Result.new 'dps' => { '111' => 1, '333' => 3, '222' => 2 }
|
37
|
+
expect(result.latest_value).to eq(3)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns nil when no datapoints are found' do
|
41
|
+
result = OpenTSDBConsumer::Result.new 'dps' => {}
|
42
|
+
expect(result.latest_value).to be_nil
|
43
|
+
end
|
44
|
+
end
|
33
45
|
end
|
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.
|
4
|
+
version: 0.3.0
|
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-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|