microphite 0.5.1 → 0.5.2
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.
- data/CHANGELOG.md +4 -0
- data/README.md +18 -18
- data/lib/microphite/client/base.rb +10 -21
- data/lib/microphite/version.rb +1 -1
- metadata +28 -22
- checksums.yaml +0 -15
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://travis-ci.org/bz-technology/microphite)
|
2
|
+
|
1
3
|
Microphite
|
2
4
|
==========
|
3
5
|
|
@@ -6,9 +8,8 @@ Overview
|
|
6
8
|
--------
|
7
9
|
|
8
10
|
Microphite is a tiny and fast, asynchronous graphite client. It can be called
|
9
|
-
many times per second with minimal overhead
|
10
|
-
|
11
|
-
can be shared across threads.
|
11
|
+
many times per second with minimal overhead. It is synchronized internally and
|
12
|
+
can be shared across threads. Both tcp and udp connections are supported.
|
12
13
|
|
13
14
|
|
14
15
|
Usage
|
@@ -18,13 +19,13 @@ Construct a standard socket client. See the 'Client Options' section below
|
|
18
19
|
for initializer options.
|
19
20
|
|
20
21
|
client = Microphite.client(
|
21
|
-
host: 'graphite.
|
22
|
+
host: 'graphite.host',
|
22
23
|
port: 2003,
|
23
24
|
transport: :udp,
|
24
|
-
prefix: '
|
25
|
+
prefix: 'app.prefix.')
|
25
26
|
|
26
27
|
Construct a client with an error_handler. The client is fault tolerant, but
|
27
|
-
an error_handler is useful for logging
|
28
|
+
an error_handler is useful for logging connection failures.
|
28
29
|
|
29
30
|
handler = Proc.new { |error| Rails.logger.error "Microphite error: #{error.message}" }
|
30
31
|
client = Microphite.client(host: '...', error_handler: handler)
|
@@ -33,32 +34,31 @@ Construct a no-op/dummy client. This is useful in development. You can leave c
|
|
33
34
|
calls in-place and the dummy client will behave appropriately.
|
34
35
|
|
35
36
|
# Initializer options are accepted, but no data is written
|
36
|
-
client = Microphite.noop(host: '
|
37
|
+
client = Microphite.noop(host: 'host', ...)
|
37
38
|
|
38
39
|
Send data points
|
39
40
|
|
40
41
|
client.write('some.key': 300, 'another.key': 25)
|
41
42
|
|
42
|
-
Accumulate counters (flushed every
|
43
|
+
Accumulate counters (flushed every :flush_interval seconds)
|
43
44
|
|
44
45
|
client.gather('some.counter': 22, 'another.counter': 10)
|
45
46
|
|
46
|
-
Time a code block
|
47
|
+
Time a code block, gathering to timing.task
|
47
48
|
|
48
|
-
client.time('
|
49
|
-
|
49
|
+
client.time('timing.task') do
|
50
|
+
task
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
+
Easy prefixing
|
53
54
|
|
54
|
-
client.prefix('
|
55
|
-
#
|
55
|
+
client.prefix('p1.') do |p1|
|
56
|
+
# Write to p1.key
|
56
57
|
app.write(key: 42)
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
sub_ns.gather(something: 5)
|
59
|
+
p1.prefix('p2.') do |p2|
|
60
|
+
# Write to p1.p2.key
|
61
|
+
p2.write(key: 5)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -45,11 +45,13 @@ module Microphite
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def write(metrics)
|
48
|
-
|
48
|
+
return false unless metrics.is_a? Hash
|
49
|
+
push(@write_queue, metrics)
|
49
50
|
end
|
50
51
|
|
51
52
|
def gather(metrics)
|
52
|
-
|
53
|
+
return false unless metrics.is_a? Hash
|
54
|
+
push(@gather_queue, metrics)
|
53
55
|
end
|
54
56
|
|
55
57
|
def prefix(prefix, &block)
|
@@ -138,10 +140,12 @@ module Microphite
|
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
141
|
-
def push(queue,
|
143
|
+
def push(queue, metrics)
|
144
|
+
timestamp = now
|
145
|
+
cloned = metrics.clone
|
142
146
|
@lock.synchronize do
|
143
147
|
if queue.length <= @limit and @status == :running
|
144
|
-
queue.push [
|
148
|
+
queue.push [timestamp, cloned]
|
145
149
|
@worker_event.signal
|
146
150
|
true
|
147
151
|
else
|
@@ -154,24 +158,9 @@ module Microphite
|
|
154
158
|
metrics = []
|
155
159
|
until queue.empty?
|
156
160
|
tuple = queue.pop
|
157
|
-
timestamp,
|
161
|
+
timestamp, hash = tuple[0], tuple[1]
|
158
162
|
wrap_errors do
|
159
|
-
|
160
|
-
when Hash
|
161
|
-
value.each_pair { |k, v| metrics << Metric.new(k, v, timestamp) }
|
162
|
-
when Array
|
163
|
-
metrics.each do |m|
|
164
|
-
if m.is_a? Metric
|
165
|
-
metrics << m
|
166
|
-
else
|
167
|
-
error(AssertionError.new("Unhandled metric type: #{value.class}"))
|
168
|
-
end
|
169
|
-
end
|
170
|
-
when Metric
|
171
|
-
metrics << value
|
172
|
-
else
|
173
|
-
error(AssertionError.new("Unhandled metric type: #{value.class}"))
|
174
|
-
end
|
163
|
+
hash.each_pair { |k, v| metrics << Metric.new(k, v, timestamp) }
|
175
164
|
end
|
176
165
|
end
|
177
166
|
metrics
|
data/lib/microphite/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Bob
|
@@ -12,37 +13,37 @@ cert_chain: []
|
|
12
13
|
date: 2013-11-20 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
15
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
16
19
|
requirements:
|
17
20
|
- - ! '>='
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
21
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
22
27
|
requirements:
|
23
28
|
- - ! '>='
|
24
29
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
-
MA==
|
27
|
-
name: rake
|
28
|
-
type: :development
|
29
|
-
prerelease: false
|
30
|
+
version: '0'
|
30
31
|
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
31
33
|
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
32
35
|
requirements:
|
33
36
|
- - ! '>='
|
34
37
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
37
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
38
43
|
requirements:
|
39
44
|
- - ! '>='
|
40
45
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
42
|
-
MA==
|
43
|
-
name: rspec
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
+
version: '0'
|
46
47
|
description: A blazing fast, thread-safe graphite client
|
47
48
|
email:
|
48
49
|
- bob@bz-technology.com
|
@@ -76,28 +77,33 @@ files:
|
|
76
77
|
- tasks/test.rake
|
77
78
|
homepage: https://github.com/bz-technology/microphite
|
78
79
|
licenses: []
|
79
|
-
metadata: {}
|
80
80
|
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
84
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
85
86
|
requirements:
|
86
87
|
- - ! '>='
|
87
88
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
|
89
|
+
version: '0'
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
hash: -4476146931496875448
|
90
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
91
95
|
requirements:
|
92
96
|
- - ! '>='
|
93
97
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
|
98
|
+
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: -4476146931496875448
|
96
102
|
requirements: []
|
97
103
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
104
|
+
rubygems_version: 1.8.23
|
99
105
|
signing_key:
|
100
|
-
specification_version:
|
106
|
+
specification_version: 3
|
101
107
|
summary: A blazing fast, thread-safe graphite client
|
102
108
|
test_files:
|
103
109
|
- spec/client/noop_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ODAzYWUzYjZkMDA2NjhmNjkxOGYwYTRmZTEwMGQwMDkyZTU3ZGNmZA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NDJkY2NlNDViYzk0ODZlM2MyZDQwODYwZmYwN2FhOGEwYTM2OTYwOQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
N2U2Zjk4ZjlmNzMyNWM1ZDM0YjZlYWQxZDU1ODI5MTc0N2FjZjdhOGY1OGFi
|
10
|
-
MGE0Yzg1NTI0ZmUxZDU4ZDAwOTgwZDZlNDEzYTkwNTJlMzUyZjQ2MGU0MTE0
|
11
|
-
ZTJlYWM2ZGUwNmFlMmExMjQwODFhNTJhYzc5NTUxNjA1MzY4ODg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGZlZWY2OGUxNzJmMGZjY2I3MzU4ZTM1NmUyNDUwNTgzYzc4ZTgxMmFmOWVk
|
14
|
-
MTQyMDZkNjkwYmQ2ZTM2M2YzODRiYzAyZDVjMTFjZDc0OWYyNjQ0Y2RjNjAx
|
15
|
-
OGMwNjExODNiMjIwMDM3YTVkZDViZGQyZjVmNmJmZjk2YjQ2Mjc=
|