measures 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/measures.rb +2 -0
- data/lib/measures/client.rb +3 -5
- data/lib/measures/transport/http.rb +28 -0
- data/lib/measures/transport/udp.rb +16 -0
- data/lib/measures/version.rb +1 -1
- data/measures.gemspec +4 -0
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb39435f2dc43dab2b8ed85647f464077e5df90e
|
4
|
+
data.tar.gz: c91af23e4c666b86a9a5dc0df7e16b6abc5223a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ba1b0f7d91602a51a5ea372a69abe97a6d3cdf84e666f2280fb85b902db39f94eb8ecc3775c495e5a9653a8f6e1c8b5fde937e0055f0f4e682edeeb2f80616
|
7
|
+
data.tar.gz: 2f8718cdbd1f9496161148eaab0a6195e14103ec1369e5865995bbdb1c5882479282bec7fc01bdda95edd73a200d221bc2720d1363a72a4f0a4f43804b83d999
|
data/README.md
CHANGED
@@ -25,8 +25,11 @@ $ gem install measures
|
|
25
25
|
```ruby
|
26
26
|
require "measures"
|
27
27
|
|
28
|
+
# Creates the transport form (UDP/HTTP/...)
|
29
|
+
transport = Measures::Transport::UDP.new("logstash.foo.bar", 30)
|
30
|
+
|
28
31
|
# Creates the measure client instance
|
29
|
-
measures = Measures::Client.new("my-app"
|
32
|
+
measures = Measures::Client.new(transport, "my-app")
|
30
33
|
|
31
34
|
# Sends count metric
|
32
35
|
measures.count("my_count_metric")
|
data/lib/measures.rb
CHANGED
data/lib/measures/client.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
require "socket"
|
2
1
|
require "json"
|
3
2
|
require "benchmark"
|
4
3
|
|
5
4
|
module Measures
|
6
5
|
class Client
|
7
|
-
def initialize(
|
6
|
+
def initialize(transport, client)
|
8
7
|
@client = client
|
9
|
-
@
|
10
|
-
@socket.connect(host, port)
|
8
|
+
@transport = transport
|
11
9
|
end
|
12
10
|
|
13
11
|
def count(metric, data = {})
|
@@ -36,7 +34,7 @@ module Measures
|
|
36
34
|
|
37
35
|
default.merge!(data)
|
38
36
|
|
39
|
-
@
|
37
|
+
@transport.send(default.to_json)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module Measures
|
6
|
+
module Transport
|
7
|
+
class HTTP
|
8
|
+
def initialize(host, port)
|
9
|
+
@host = host
|
10
|
+
@port = port
|
11
|
+
end
|
12
|
+
|
13
|
+
def send(data)
|
14
|
+
client = Faraday.new(url: URI::HTTP.build(host: @host, port: @port)) do |c|
|
15
|
+
c.request :json
|
16
|
+
|
17
|
+
c.adapter Faraday.default_adapter
|
18
|
+
end
|
19
|
+
|
20
|
+
client.post do |req|
|
21
|
+
req.url "/"
|
22
|
+
req.headers["Content-Type"] = "application/json"
|
23
|
+
req.body = data
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/measures/version.rb
CHANGED
data/measures.gemspec
CHANGED
@@ -15,9 +15,13 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
+
spec.add_dependency "faraday"
|
19
|
+
spec.add_dependency "faraday_middleware"
|
20
|
+
|
18
21
|
spec.add_development_dependency "bundler", "~> 1.11"
|
19
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
20
23
|
spec.add_development_dependency "rspec"
|
21
24
|
spec.add_development_dependency "guard"
|
22
25
|
spec.add_development_dependency "guard-rspec"
|
26
|
+
spec.add_development_dependency "webmock"
|
23
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: measures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Boeira
|
@@ -9,8 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday_middleware
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
14
42
|
- !ruby/object:Gem::Dependency
|
15
43
|
name: bundler
|
16
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,6 +109,20 @@ dependencies:
|
|
81
109
|
- - ">="
|
82
110
|
- !ruby/object:Gem::Version
|
83
111
|
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: webmock
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
84
126
|
description: Measures ruby client
|
85
127
|
email:
|
86
128
|
- me@marceloboeira.com
|
@@ -100,6 +142,8 @@ files:
|
|
100
142
|
- bin/setup
|
101
143
|
- lib/measures.rb
|
102
144
|
- lib/measures/client.rb
|
145
|
+
- lib/measures/transport/http.rb
|
146
|
+
- lib/measures/transport/udp.rb
|
103
147
|
- lib/measures/version.rb
|
104
148
|
- measures.gemspec
|
105
149
|
homepage: ''
|