opentsdb 0.1.1 → 0.2.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 +7 -0
- data/.travis.yml +5 -0
- data/Gemfile +1 -1
- data/README.md +3 -0
- data/lib/opentsdb/client.rb +14 -2
- data/lib/opentsdb/version.rb +1 -1
- data/spec/client_spec.rb +34 -0
- metadata +15 -25
- data/.rvmrc +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9c05b82d4390fd75cad12cf522d8d85a4ad3120
|
4
|
+
data.tar.gz: 9d7453a648b67f73f0086c992f4f7e8c6b77e247
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80126de66e433fa14a7cf4474fc2f042978b870c0f95811c214e4c359b3ab289167cc832e8de37f3cb9de2782e34a20f1782e6abcbb658f186cf2d4e6823ea00
|
7
|
+
data.tar.gz: b80ebfbd5e83730c3aa4074828bf7da05861fc8a54ffac2436d5bce5bc9621cc6846e17e24e56d994f1f5934dd26e2e956511865dbe97cbd7bd4e4128c1e1607
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/opentsdb/client.rb
CHANGED
@@ -17,12 +17,24 @@ module OpenTSDB
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def to_command( options )
|
21
21
|
timestamp = options[:timestamp].to_i
|
22
22
|
metric_name = options[:metric]
|
23
23
|
value = options[:value].to_f
|
24
24
|
tags = options[:tags].map{|k,v| "#{k}=#{v}"}.join(" ")
|
25
|
-
|
25
|
+
"put #{metric_name} #{timestamp} #{value} #{tags}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_command(input)
|
29
|
+
if input.kind_of?(Array)
|
30
|
+
input.collect { |unit| to_command(unit) }.join("\n")
|
31
|
+
else
|
32
|
+
to_command(input)
|
33
|
+
end.chomp
|
34
|
+
end
|
35
|
+
|
36
|
+
def put(options = {})
|
37
|
+
@connection.puts(build_command(options))
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/opentsdb/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -2,10 +2,44 @@ require 'spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe OpenTSDB::Client do
|
4
4
|
before :each do
|
5
|
+
@socket = double('socket').as_null_object
|
6
|
+
expect(TCPSocket).to receive(:new).and_return(@socket)
|
5
7
|
@client = OpenTSDB::Client.new
|
6
8
|
end
|
7
9
|
|
8
10
|
it "should create a new client" do
|
9
11
|
end
|
12
|
+
|
13
|
+
it "should write a single metric to the socket" do
|
14
|
+
expect(@socket).to receive(:puts).with("put users 1411104988 100.0 foo=bar")
|
15
|
+
metric = {
|
16
|
+
:timestamp => 1411104988,
|
17
|
+
:metric => "users",
|
18
|
+
:value => 100,
|
19
|
+
:tags => { :foo => "bar" }
|
20
|
+
}
|
21
|
+
@client.put(metric)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should write multiple metrics to the socket" do
|
25
|
+
expect(@socket).to receive(:puts).with("put users 1411104988 100.0 foo=bar\nput users 1411104999 150.0 bar=baz")
|
26
|
+
metrics = []
|
27
|
+
metrics << {
|
28
|
+
:timestamp => 1411104988,
|
29
|
+
:metric => "users",
|
30
|
+
:value => 100,
|
31
|
+
:tags => { :foo => "bar" }
|
32
|
+
}
|
33
|
+
|
34
|
+
metrics << {
|
35
|
+
:timestamp => 1411104999,
|
36
|
+
:metric => "users",
|
37
|
+
:value => 150,
|
38
|
+
:tags => { :bar => "baz" }
|
39
|
+
}
|
40
|
+
|
41
|
+
@client.put(metrics)
|
42
|
+
|
43
|
+
end
|
10
44
|
|
11
45
|
end
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentsdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Ewart
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: simplecov
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.3.8
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.3.8
|
46
41
|
description: A Ruby implementation of a client library for sending data points to
|
@@ -52,7 +47,7 @@ extensions: []
|
|
52
47
|
extra_rdoc_files: []
|
53
48
|
files:
|
54
49
|
- .gitignore
|
55
|
-
- .
|
50
|
+
- .travis.yml
|
56
51
|
- CHANGELOG.md
|
57
52
|
- Gemfile
|
58
53
|
- LICENSE
|
@@ -70,32 +65,27 @@ files:
|
|
70
65
|
homepage: https://github.com/johnewart/ruby-opentsdb
|
71
66
|
licenses:
|
72
67
|
- MIT
|
68
|
+
metadata: {}
|
73
69
|
post_install_message:
|
74
70
|
rdoc_options: []
|
75
71
|
require_paths:
|
76
72
|
- lib
|
77
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
74
|
requirements:
|
80
|
-
- -
|
75
|
+
- - '>='
|
81
76
|
- !ruby/object:Gem::Version
|
82
77
|
version: '0'
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
hash: 311338383
|
86
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
79
|
requirements:
|
89
|
-
- -
|
80
|
+
- - '>='
|
90
81
|
- !ruby/object:Gem::Version
|
91
82
|
version: '0'
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
hash: 311338383
|
95
83
|
requirements: []
|
96
84
|
rubyforge_project: opentsdb
|
97
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.2.2
|
98
86
|
signing_key:
|
99
|
-
specification_version:
|
87
|
+
specification_version: 4
|
100
88
|
summary: Ruby client for OpenTSDB
|
101
|
-
test_files:
|
89
|
+
test_files:
|
90
|
+
- spec/client_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm ruby-1.9.3@opentsdb
|