measures 2.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -3
- data/lib/measures/client.rb +4 -2
- data/lib/measures/transports/http.rb +37 -0
- data/lib/measures/{transport → transports}/udp.rb +1 -1
- data/lib/measures/version.rb +1 -1
- data/lib/measures.rb +2 -2
- metadata +5 -6
- data/lib/measures/transport/http.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eb0595ec25d36acf478b600a21631094bb9560a4bfe6b30b21e0af0e4aef3cc4
|
4
|
+
data.tar.gz: '02180667c0ae4dda2d30b85dd5d4f8f7b9a647df9e5911e32501d6e61b577afa'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5acdcecad5ab2dddc812eb2eb2befa43c87c69a2e5b35d831b5389eaba13c80b06ecb0a6875973d31be1ba540c9a3c0185e61ea12c49e1342cb18e0cdfe35cb4
|
7
|
+
data.tar.gz: 54f1fa67878974c9e9278fa5045267e5e8def6d8b51b98cbd1253b23fbc003b388d2523e01a3acd066f30a1b1c295c4d986be97d4d461853a88eebb230a0ee62
|
data/README.md
CHANGED
@@ -25,11 +25,11 @@ $ gem install measures
|
|
25
25
|
```ruby
|
26
26
|
require "measures"
|
27
27
|
|
28
|
-
# Creates the transport
|
29
|
-
transport = Measures::
|
28
|
+
# Creates the transport (UDP/HTTP/...)
|
29
|
+
transport = Measures::Transports::UDP.new("logstash.foo.bar", 30)
|
30
30
|
|
31
31
|
# Creates the measure client instance
|
32
|
-
measures = Measures::Client.new(transport, "my-app")
|
32
|
+
measures = Measures::Client.new(transport, "my-app", "my-team")
|
33
33
|
|
34
34
|
# Sends count metric
|
35
35
|
measures.count("my_count_metric")
|
data/lib/measures/client.rb
CHANGED
@@ -3,9 +3,10 @@ require "benchmark"
|
|
3
3
|
|
4
4
|
module Measures
|
5
5
|
class Client
|
6
|
-
def initialize(transport, client)
|
6
|
+
def initialize(transport, client, owner)
|
7
7
|
@client = client
|
8
8
|
@transport = transport
|
9
|
+
@owner = owner
|
9
10
|
end
|
10
11
|
|
11
12
|
def count(metric, data = {})
|
@@ -28,8 +29,9 @@ module Measures
|
|
28
29
|
|
29
30
|
def send(metric, data = {})
|
30
31
|
default = {
|
32
|
+
"owner" => @owner,
|
31
33
|
"client" => @client,
|
32
|
-
"metric" => metric
|
34
|
+
"metric" => metric
|
33
35
|
}
|
34
36
|
|
35
37
|
default.merge!(data)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module Measures
|
6
|
+
module Transports
|
7
|
+
class HTTP
|
8
|
+
def initialize(host, port = 80, url = "/", open_timeout = 30, timeout = 30)
|
9
|
+
@host = host
|
10
|
+
@port = port
|
11
|
+
@url = url
|
12
|
+
@open_timeout = open_timeout
|
13
|
+
@timeout = timeout
|
14
|
+
end
|
15
|
+
|
16
|
+
def send(data)
|
17
|
+
client.post do |req|
|
18
|
+
req.url @url
|
19
|
+
req.headers["Content-Type"] = "application/json"
|
20
|
+
req.body = data
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def client
|
25
|
+
Faraday.new(url: URI::HTTP.build(host: @host, port: @port)) do |c|
|
26
|
+
c.request :json
|
27
|
+
|
28
|
+
c.options[:open_timeout] = @open_timeout
|
29
|
+
c.options[:timeout] = @timeout
|
30
|
+
|
31
|
+
c.response :raise_error
|
32
|
+
c.adapter Faraday.default_adapter
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/measures/version.rb
CHANGED
data/lib/measures.rb
CHANGED
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: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Boeira
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -142,8 +142,8 @@ files:
|
|
142
142
|
- bin/setup
|
143
143
|
- lib/measures.rb
|
144
144
|
- lib/measures/client.rb
|
145
|
-
- lib/measures/
|
146
|
-
- lib/measures/
|
145
|
+
- lib/measures/transports/http.rb
|
146
|
+
- lib/measures/transports/udp.rb
|
147
147
|
- lib/measures/version.rb
|
148
148
|
- measures.gemspec
|
149
149
|
homepage: ''
|
@@ -166,9 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.7.10
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Measures ruby client
|
173
173
|
test_files: []
|
174
|
-
has_rdoc:
|
@@ -1,28 +0,0 @@
|
|
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
|