rubycut-metriks 0.9.9.8 → 0.9.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
- source :rubygems
2
-
1
+ source 'https://rubygems.org'
3
2
  gemspec
4
3
 
5
4
  group :test do
6
- gem 'ruby-debug'
5
+ gem 'ruby-debug', :platform => :mri_18
7
6
  gem 'rake', '0.8.7'
8
7
  gem 'riemann-client', '~> 0.0.7'
9
8
  gem 'rbtree', :platform => :mri_18
@@ -0,0 +1,113 @@
1
+ require 'net/https'
2
+ require 'socket'
3
+ require 'io/wait'
4
+ require 'cql'
5
+
6
+ module Metriks::Reporter
7
+ class Cassandra
8
+ attr_accessor :prefix, :source
9
+
10
+ def initialize(host, options = {})
11
+ @host = host
12
+ @port = options[:port] || "9042"
13
+ @prefix = options[:prefix]
14
+ @source = options[:source]
15
+ @database = options[:database]
16
+ @table = options[:table]
17
+ @interval = options[:interval] || 60
18
+ @registry = options[:registry] || Metriks::Registry.default
19
+ @on_error = options[:on_error] || proc { |ex| }
20
+
21
+ end
22
+ def open_connection
23
+ @connection = Cql::Client.connect(host: @host, port: @port)
24
+ @connection.use(@database)
25
+ @connection
26
+ end
27
+ def connection
28
+ @connection
29
+ end
30
+ def start
31
+ @thread ||= Thread.new do
32
+ loop do
33
+ sleep @interval
34
+ Thread.new do
35
+ begin
36
+ write
37
+ rescue Exception => ex
38
+ @on_error[ex] rescue nil
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def stop
46
+ @thread.kill if @thread
47
+ @thread = nil
48
+ end
49
+
50
+ def restart
51
+ stop
52
+ start
53
+ end
54
+
55
+ def write
56
+ open_connection
57
+ @registry.each do |name, metric|
58
+ case metric
59
+ when Metriks::Meter
60
+ send_metric name, metric, [
61
+ :count, :one_minute_rate, :five_minute_rate,
62
+ :fifteen_minute_rate, :mean_rate
63
+ ]
64
+ when Metriks::Counter
65
+ send_metric name, metric, [
66
+ :count
67
+ ]
68
+ metric.clear if metric.reset_on_submit
69
+ when Metriks::Gauge
70
+ send_metric name, metric, [
71
+ :value
72
+ ]
73
+ when Metriks::UtilizationTimer
74
+ send_metric name, metric, [
75
+ :count, :one_minute_rate, :five_minute_rate,
76
+ :fifteen_minute_rate, :mean_rate,
77
+ :min, :max, :mean, :stddev,
78
+ :one_minute_utilization, :five_minute_utilization,
79
+ :fifteen_minute_utilization, :mean_utilization,
80
+ ], [
81
+ :median, :get_95th_percentile
82
+ ]
83
+ when Metriks::Timer
84
+ send_metric name, metric, [
85
+ :count, :one_minute_rate, :five_minute_rate,
86
+ :fifteen_minute_rate, :mean_rate,
87
+ :min, :max, :mean, :stddev
88
+ ], [
89
+ :median, :get_95th_percentile
90
+ ]
91
+ when Metriks::Histogram
92
+ send_metric name, metric, [
93
+ :count, :min, :max, :mean, :stddev
94
+ ], [
95
+ :median, :get_95th_percentile
96
+ ]
97
+ end
98
+ end
99
+ close_connection
100
+
101
+ end
102
+ def close_connection
103
+ connection.close
104
+ end
105
+ def send_metric(compound_name, metric, keys, snapshot_keys = [])
106
+ keys.each do |key|
107
+ command = "INSERT INTO #{@table} (server,metric,time,v) VALUES ('#{@source}','#{compound_name}','#{Time.now.utc.strftime("%Y-%m-%d %H:%M:%S+0000")}',#{metric.send(key)})"
108
+ puts command
109
+ connection.execute command
110
+ end
111
+ end
112
+ end
113
+ end
@@ -107,7 +107,7 @@ module Metriks::Reporter
107
107
  connection.puts("put #{name} #{Time.now.to_i} #{metric.send(keys.first)} #{tags}")
108
108
  else
109
109
  keys.each do |key|
110
- puts "put #{name}.#{key} #{Time.now.to_i} #{metric.send(key)} #{tags}"
110
+ #puts "put #{name}.#{key} #{Time.now.to_i} #{metric.send(key)} #{tags}"
111
111
  connection.puts("put #{name}.#{key} #{Time.now.to_i} #{metric.send(key)} #{tags}")
112
112
  end
113
113
  end
data/metriks.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'rubycut-metriks'
16
- s.version = '0.9.9.8'
17
- s.date = '2013-05-30'
16
+ s.version = '0.9.9.9'
17
+ s.date = '2013-10-29'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_dependency('atomic', ["~> 1.0"])
43
43
  s.add_dependency('hitimes', [ "~> 1.1"])
44
44
  s.add_dependency('avl_tree', [ "~> 1.1.2" ])
45
+ s.add_dependency('cql-rb', [ ">= 1.0.5" ])
45
46
 
46
47
  ## List your development dependencies here. Development dependencies are
47
48
  ## those that are only needed during development
@@ -72,6 +73,7 @@ Gem::Specification.new do |s|
72
73
  lib/metriks/reporter/proc_title.rb
73
74
  lib/metriks/reporter/riemann.rb
74
75
  lib/metriks/reporter/opentsdb.rb
76
+ lib/metriks/reporter/cassandra.rb
75
77
  lib/metriks/simple_moving_average.rb
76
78
  lib/metriks/snapshot.rb
77
79
  lib/metriks/time_tracker.rb
@@ -1,6 +1,5 @@
1
1
  require 'test_helper'
2
2
  require 'thread_error_handling_tests'
3
- require 'ruby-debug'
4
3
  require 'metriks/reporter/opentsdb'
5
4
 
6
5
  class OpentsdbReporterTest < Test::Unit::TestCase
metadata CHANGED
@@ -1,94 +1,104 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubycut-metriks
3
- version: !ruby/object:Gem::Version
4
- hash: 51
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.9.9
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 9
10
- - 8
11
- version: 0.9.9.8
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - Eric Lindvall
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2013-05-30 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: atomic
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 1
32
- - 0
33
- version: "1.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: hitimes
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hitimes
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
34
+ requirements:
42
35
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 13
45
- segments:
46
- - 1
47
- - 1
48
- version: "1.1"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
49
38
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
52
47
  name: avl_tree
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.2
54
+ type: :runtime
53
55
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
55
57
  none: false
56
- requirements:
58
+ requirements:
57
59
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 23
60
- segments:
61
- - 1
62
- - 1
63
- - 2
60
+ - !ruby/object:Gem::Version
64
61
  version: 1.1.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: cql-rb
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.5
65
70
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: mocha
69
71
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
71
73
  none: false
72
- requirements:
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: mocha
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
73
83
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 31
76
- segments:
77
- - 0
78
- - 10
79
- version: "0.10"
84
+ - !ruby/object:Gem::Version
85
+ version: '0.10'
80
86
  type: :development
81
- version_requirements: *id004
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.10'
82
94
  description: An experimental metrics client.
83
95
  email: eric@sevenscale.com
84
96
  executables: []
85
-
86
97
  extensions: []
87
-
88
- extra_rdoc_files:
98
+ extra_rdoc_files:
89
99
  - README.md
90
100
  - LICENSE
91
- files:
101
+ files:
92
102
  - Gemfile
93
103
  - LICENSE
94
104
  - README.md
@@ -108,6 +118,7 @@ files:
108
118
  - lib/metriks/reporter/proc_title.rb
109
119
  - lib/metriks/reporter/riemann.rb
110
120
  - lib/metriks/reporter/opentsdb.rb
121
+ - lib/metriks/reporter/cassandra.rb
111
122
  - lib/metriks/simple_moving_average.rb
112
123
  - lib/metriks/snapshot.rb
113
124
  - lib/metriks/time_tracker.rb
@@ -132,38 +143,30 @@ files:
132
143
  - test/opentsdb_metrics_reporter_test.rb
133
144
  homepage: https://github.com/rubycut/metriks
134
145
  licenses: []
135
-
136
146
  post_install_message:
137
- rdoc_options:
147
+ rdoc_options:
138
148
  - --charset=UTF-8
139
- require_paths:
149
+ require_paths:
140
150
  - lib
141
- required_ruby_version: !ruby/object:Gem::Requirement
151
+ required_ruby_version: !ruby/object:Gem::Requirement
142
152
  none: false
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- hash: 3
147
- segments:
148
- - 0
149
- version: "0"
150
- required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
158
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 3
156
- segments:
157
- - 0
158
- version: "0"
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
159
163
  requirements: []
160
-
161
164
  rubyforge_project:
162
- rubygems_version: 1.8.25
165
+ rubygems_version: 1.8.23
163
166
  signing_key:
164
167
  specification_version: 2
165
168
  summary: An experimental metrics client
166
- test_files:
169
+ test_files:
167
170
  - test/counter_test.rb
168
171
  - test/graphite_reporter_test.rb
169
172
  - test/histogram_test.rb
@@ -177,3 +180,4 @@ test_files:
177
180
  - test/timer_test.rb
178
181
  - test/utilization_timer_test.rb
179
182
  - test/opentsdb_metrics_reporter_test.rb
183
+ has_rdoc: