rubycut-metriks 0.9.9.10 → 0.9.9.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,9 +20,11 @@ module Metriks::Reporter
20
20
 
21
21
  end
22
22
  def open_connection
23
- @connection = Cql::Client.connect(host: @host, port: @port)
23
+ @connection = Cql::Client.connect(host: @host)
24
24
  @connection.use(@database)
25
- @connection
25
+
26
+ @write_statement = @connection.prepare("INSERT INTO #{@table}(server,metric, time, v) VALUES
27
+ (?, ?, ?, ?) USING TTL 1209600") # two weeks
26
28
  end
27
29
  def connection
28
30
  @connection
@@ -96,6 +98,7 @@ module Metriks::Reporter
96
98
  ]
97
99
  end
98
100
  end
101
+ sleep 2
99
102
  close_connection
100
103
 
101
104
  end
@@ -104,10 +107,18 @@ module Metriks::Reporter
104
107
  end
105
108
  def send_metric(compound_name, metric, keys, snapshot_keys = [])
106
109
  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
+ execute_prepared_statement [@source,compound_name,"#{Time.now.to_i}",metric.send(key)]
111
+ end
112
+ end
113
+ def execute_prepared_statement array
114
+ future = write_statement.async.execute(*array)
115
+ future.on_failure do |error|
116
+ raise error
110
117
  end
111
118
  end
119
+ def write_statement
120
+ @write_statement
121
+ end
122
+
112
123
  end
113
124
  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.10'
17
- s.date = '2013-12-04'
16
+ s.version = '0.9.9.11'
17
+ s.date = '2014-01-03'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycut-metriks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9.10
4
+ version: 0.9.9.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-04 00:00:00.000000000 Z
12
+ date: 2014-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: atomic