anschel 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/anschel/main.rb +29 -1
- data/lib/anschel/stats.rb +7 -36
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d32db0a5fe08817a91ac24c3d3e4cc57b53ce01
|
4
|
+
data.tar.gz: 4df5ae73011b3c6a8952b6c6366007f24241e842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73111befe962052809308f788bbb2ccf306992fbc0cbc2360f65c6ee107002c75e473768f8c970b211ee219d189671b72c8c1d0892c23c5f14fe66f384b1c41f
|
7
|
+
data.tar.gz: 1ee9dca9c94e851293b68beeff95221453245095cc81c636e570bad128e3d6510cbf9c17d02093a5f214e8dad2ded951ee2e383f199f2bd84fe11935e6a371e4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.10
|
data/lib/anschel/main.rb
CHANGED
@@ -2,6 +2,7 @@ require 'logger'
|
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
4
|
require 'jrjackson'
|
5
|
+
require 'rack'
|
5
6
|
|
6
7
|
require_relative 'mjolnir'
|
7
8
|
require_relative 'metadata'
|
@@ -68,7 +69,12 @@ module Anschel
|
|
68
69
|
stats.create 'event'
|
69
70
|
stats.get 'event'
|
70
71
|
|
71
|
-
ts =
|
72
|
+
ts = []
|
73
|
+
|
74
|
+
stats_port = config[:stats_port] || 3345
|
75
|
+
ts << stats_endpoint(stats, stats_port, log)
|
76
|
+
|
77
|
+
ts += num_cpus.times.map do
|
72
78
|
Thread.new do
|
73
79
|
loop do
|
74
80
|
event = JrJackson::Json.load \
|
@@ -113,5 +119,27 @@ module Anschel
|
|
113
119
|
log.send level, event: 'goodbye', version: VERSION
|
114
120
|
end
|
115
121
|
|
122
|
+
|
123
|
+
def stats_endpoint stats, stats_port, log
|
124
|
+
ok = '200'
|
125
|
+
json = { 'Content-Type' => 'application/json' }
|
126
|
+
|
127
|
+
app = lambda do |_|
|
128
|
+
hash_stats = { version: VERSION }.merge stats.read
|
129
|
+
json_stats = JSON.pretty_generate hash_stats
|
130
|
+
[ ok, json, [ json_stats ] ]
|
131
|
+
end
|
132
|
+
|
133
|
+
t = Thread.new do
|
134
|
+
Rack::Handler::WEBrick.run app, \
|
135
|
+
Port: stats_port,
|
136
|
+
Logger: log,
|
137
|
+
AccessLog: []
|
138
|
+
end
|
139
|
+
|
140
|
+
log.info event: 'serving-metrics', port: stats_port
|
141
|
+
return t
|
142
|
+
end
|
143
|
+
|
116
144
|
end
|
117
145
|
end
|
data/lib/anschel/stats.rb
CHANGED
@@ -10,22 +10,14 @@ module Anschel
|
|
10
10
|
@interval = interval || 30
|
11
11
|
@stats = Hash.new
|
12
12
|
@lock = Mutex.new
|
13
|
-
|
14
|
-
Thread.new do
|
15
|
-
loop do
|
16
|
-
sleep @interval
|
17
|
-
report_and_reset
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
13
|
@logger.info event: 'stats-loaded'
|
22
14
|
end
|
23
15
|
|
16
|
+
def read ; stats end
|
24
17
|
|
25
|
-
def create name,
|
18
|
+
def create name, init=0
|
26
19
|
with_lock do
|
27
|
-
stats[name] =
|
28
|
-
stats[name].default = default
|
20
|
+
stats[name] = init
|
29
21
|
stats
|
30
22
|
end
|
31
23
|
end
|
@@ -38,25 +30,25 @@ module Anschel
|
|
38
30
|
|
39
31
|
def inc name, by=1
|
40
32
|
with_lock do
|
41
|
-
stats[name]
|
33
|
+
stats[name] += by
|
42
34
|
end
|
43
35
|
end
|
44
36
|
|
45
37
|
def dec name, by=1
|
46
38
|
with_lock do
|
47
|
-
stats[name]
|
39
|
+
stats[name] -= by
|
48
40
|
end
|
49
41
|
end
|
50
42
|
|
51
43
|
def set name, to
|
52
44
|
with_lock do
|
53
|
-
stats[name]
|
45
|
+
stats[name] = to
|
54
46
|
end
|
55
47
|
end
|
56
48
|
|
57
49
|
def get name
|
58
50
|
with_lock do
|
59
|
-
stats[name]
|
51
|
+
stats[name]
|
60
52
|
end
|
61
53
|
end
|
62
54
|
|
@@ -69,26 +61,5 @@ module Anschel
|
|
69
61
|
yield
|
70
62
|
end
|
71
63
|
end
|
72
|
-
|
73
|
-
def report_and_reset
|
74
|
-
ready_stats = with_lock do
|
75
|
-
stats.keys.flat_map do |k|
|
76
|
-
v = stats[k].delete(:val)
|
77
|
-
v ||= stats[k].default
|
78
|
-
stats[k][:val] = stats[k].default
|
79
|
-
[
|
80
|
-
[ k, v ],
|
81
|
-
[ "#{k}-rate", 1.0 * v / @interval ]
|
82
|
-
]
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
return if stats.empty?
|
87
|
-
@logger.info \
|
88
|
-
event: 'stats',
|
89
|
-
version: Anschel::VERSION,
|
90
|
-
interval: @interval,
|
91
|
-
stats: Hash[ready_stats]
|
92
|
-
end
|
93
64
|
end
|
94
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anschel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.13'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.6'
|
117
|
+
name: rack
|
118
|
+
prerelease: false
|
119
|
+
type: :runtime
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.6'
|
111
125
|
description: Logstash-like for moving events from Kafka into Elasticsearch.
|
112
126
|
email: sczizzo@gmail.com
|
113
127
|
executables:
|
@@ -167,4 +181,3 @@ signing_key:
|
|
167
181
|
specification_version: 4
|
168
182
|
summary: Logstash-like for moving events from Kafka into Elasticsearch
|
169
183
|
test_files: []
|
170
|
-
has_rdoc:
|