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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb39435f2dc43dab2b8ed85647f464077e5df90e
4
- data.tar.gz: c91af23e4c666b86a9a5dc0df7e16b6abc5223a8
2
+ SHA256:
3
+ metadata.gz: eb0595ec25d36acf478b600a21631094bb9560a4bfe6b30b21e0af0e4aef3cc4
4
+ data.tar.gz: '02180667c0ae4dda2d30b85dd5d4f8f7b9a647df9e5911e32501d6e61b577afa'
5
5
  SHA512:
6
- metadata.gz: 26ba1b0f7d91602a51a5ea372a69abe97a6d3cdf84e666f2280fb85b902db39f94eb8ecc3775c495e5a9653a8f6e1c8b5fde937e0055f0f4e682edeeb2f80616
7
- data.tar.gz: 2f8718cdbd1f9496161148eaab0a6195e14103ec1369e5865995bbdb1c5882479282bec7fc01bdda95edd73a200d221bc2720d1363a72a4f0a4f43804b83d999
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 form (UDP/HTTP/...)
29
- transport = Measures::Transport::UDP.new("logstash.foo.bar", 30)
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")
@@ -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
@@ -1,7 +1,7 @@
1
1
  require "socket"
2
2
 
3
3
  module Measures
4
- module Transport
4
+ module Transports
5
5
  class UDP
6
6
  def initialize(host, port)
7
7
  @socket = UDPSocket.new
@@ -1,3 +1,3 @@
1
1
  module Measures
2
- VERSION = "2.0.0"
2
+ VERSION = "5.0.0"
3
3
  end
data/lib/measures.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "measures/version"
2
2
  require "measures/client"
3
- require "measures/transport/udp"
4
- require "measures/transport/http"
3
+ require "measures/transports/udp"
4
+ require "measures/transports/http"
5
5
 
6
6
  module Measures; 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: 2.0.0
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: 2016-04-12 00:00:00.000000000 Z
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/transport/http.rb
146
- - lib/measures/transport/udp.rb
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.5.1
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