measures 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +14 -0
- data/LICENSE +1 -1
- data/README.md +22 -5
- data/lib/measures/client.rb +22 -4
- data/lib/measures/version.rb +1 -1
- data/measures.gemspec +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5762e573fb1e82f50eae006d466fb725e57524cd
|
4
|
+
data.tar.gz: 8e6bd6539060a82e7607aa76d988d9815d1bd95c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 374ce521a3665d9d7125ff628a55e1db326ce6d738deb2d60c92456d710f1a3f5b57b964376d28979e8dd13309652e3280f7d5189d76ed93c9df75fd9842a2a5
|
7
|
+
data.tar.gz: dce0f1c8a36464afdcc1fbf33368f256374acea8989ab5baa55f47a1c2f8fe07dbf993a2a18c7e4369c2149bb15b476f331c1d7ac6e66b610604979ea05be800
|
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -28,9 +28,26 @@ require "measures"
|
|
28
28
|
# Creates the measure client instance
|
29
29
|
measures = Measures::Client.new("my-app", "logstash.foo.bar", 30)
|
30
30
|
|
31
|
-
# Sends metric
|
32
|
-
measures.count("
|
33
|
-
|
34
|
-
# Sends metric with additional data
|
35
|
-
measures.count("
|
31
|
+
# Sends count metric
|
32
|
+
measures.count("my_count_metric")
|
33
|
+
|
34
|
+
# Sends count metric with additional data
|
35
|
+
measures.count("my_count_metric", { "foo" => "bar" })
|
36
|
+
|
37
|
+
# Sends time metric
|
38
|
+
measures.time("my_time_metric") do
|
39
|
+
# Some long operations
|
40
|
+
sleep(10)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sends time metric with additional data
|
44
|
+
measures.time("my_time_metric", { "foo" => "bar" }) do
|
45
|
+
# Some long operations
|
46
|
+
sleep(10)
|
47
|
+
end
|
36
48
|
```
|
49
|
+
|
50
|
+
## Measures in other languages
|
51
|
+
|
52
|
+
- [Python](https://github.com/globocom/measures)
|
53
|
+
- [Go](https://github.com/scorphus/measures)
|
data/lib/measures/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "socket"
|
2
2
|
require "json"
|
3
|
+
require "benchmark"
|
3
4
|
|
4
5
|
module Measures
|
5
6
|
class Client
|
@@ -10,15 +11,32 @@ module Measures
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def count(metric, data = {})
|
13
|
-
|
14
|
+
data.merge!({ "count" => 1 })
|
15
|
+
|
16
|
+
send(metric, data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def time(metric, data = {}, &block)
|
20
|
+
elapsed_time = Benchmark.realtime do
|
21
|
+
yield if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
data.merge!({ "time" => elapsed_time })
|
25
|
+
|
26
|
+
send(metric, data)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def send(metric, data = {})
|
32
|
+
default = {
|
14
33
|
"client" => @client,
|
15
34
|
"metric" => metric,
|
16
|
-
"count" => 1,
|
17
35
|
}
|
18
36
|
|
19
|
-
|
37
|
+
default.merge!(data)
|
20
38
|
|
21
|
-
@socket.send(
|
39
|
+
@socket.send(default.to_json, 0)
|
22
40
|
end
|
23
41
|
end
|
24
42
|
end
|
data/lib/measures/version.rb
CHANGED
data/measures.gemspec
CHANGED
@@ -18,4 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.add_development_dependency "bundler", "~> 1.11"
|
19
19
|
spec.add_development_dependency "rake", "~> 10.0"
|
20
20
|
spec.add_development_dependency "rspec"
|
21
|
+
spec.add_development_dependency "guard"
|
22
|
+
spec.add_development_dependency "guard-rspec"
|
21
23
|
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: 1.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
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -53,6 +53,34 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: guard
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: guard-rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
56
84
|
description: Measures ruby client
|
57
85
|
email:
|
58
86
|
- me@marceloboeira.com
|
@@ -64,6 +92,7 @@ files:
|
|
64
92
|
- ".gitignore"
|
65
93
|
- ".rspec"
|
66
94
|
- Gemfile
|
95
|
+
- Guardfile
|
67
96
|
- LICENSE
|
68
97
|
- README.md
|
69
98
|
- Rakefile
|