simple_metrics 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/README.markdown +53 -16
  2. data/Rakefile +0 -17
  3. data/bin/populate +13 -26
  4. data/bin/simple_metrics_client +64 -0
  5. data/bin/simple_metrics_server +3 -4
  6. data/lib/simple_metrics.rb +76 -17
  7. data/lib/simple_metrics/bucket.rb +106 -43
  8. data/lib/simple_metrics/client.rb +83 -0
  9. data/lib/simple_metrics/data_point.rb +137 -45
  10. data/lib/simple_metrics/functions.rb +5 -5
  11. data/lib/simple_metrics/graph.rb +32 -69
  12. data/lib/simple_metrics/mongo.rb +48 -0
  13. data/lib/simple_metrics/server.rb +66 -0
  14. data/lib/simple_metrics/version.rb +1 -1
  15. data/simple_metrics.gemspec +0 -6
  16. data/spec/bucket_spec.rb +152 -17
  17. data/spec/data_point_spec.rb +64 -14
  18. data/spec/graph_spec.rb +19 -30
  19. data/spec/spec_helper.rb +3 -3
  20. metadata +24 -139
  21. data/.travis.yml +0 -3
  22. data/bin/simple_metrics_web +0 -11
  23. data/config.ru +0 -6
  24. data/default_config.yml +0 -34
  25. data/lib/simple_metrics/app.rb +0 -52
  26. data/lib/simple_metrics/configuration.rb +0 -97
  27. data/lib/simple_metrics/data_point/base.rb +0 -59
  28. data/lib/simple_metrics/data_point/counter.rb +0 -20
  29. data/lib/simple_metrics/data_point/event.rb +0 -16
  30. data/lib/simple_metrics/data_point/gauge.rb +0 -19
  31. data/lib/simple_metrics/data_point/timing.rb +0 -15
  32. data/lib/simple_metrics/data_point_repository.rb +0 -114
  33. data/lib/simple_metrics/importer.rb +0 -64
  34. data/lib/simple_metrics/metric.rb +0 -29
  35. data/lib/simple_metrics/metric_repository.rb +0 -54
  36. data/lib/simple_metrics/public/css/bootstrap-responsive.min.css +0 -12
  37. data/lib/simple_metrics/public/css/bootstrap.min.css +0 -689
  38. data/lib/simple_metrics/public/css/graph.css +0 -45
  39. data/lib/simple_metrics/public/css/rickshaw.min.css +0 -1
  40. data/lib/simple_metrics/public/img/glyphicons-halflings-white.png +0 -0
  41. data/lib/simple_metrics/public/img/glyphicons-halflings.png +0 -0
  42. data/lib/simple_metrics/public/js/app.js +0 -20
  43. data/lib/simple_metrics/public/js/collections/graph.js +0 -16
  44. data/lib/simple_metrics/public/js/collections/metric.js +0 -9
  45. data/lib/simple_metrics/public/js/helpers.js +0 -23
  46. data/lib/simple_metrics/public/js/lib/backbone-0.9.2.min.js +0 -38
  47. data/lib/simple_metrics/public/js/lib/bootstrap.min.js +0 -6
  48. data/lib/simple_metrics/public/js/lib/d3.v2.min.js +0 -4
  49. data/lib/simple_metrics/public/js/lib/handlebars-1.0.0.beta.6.js +0 -1550
  50. data/lib/simple_metrics/public/js/lib/jquery-1.7.1.min.js +0 -4
  51. data/lib/simple_metrics/public/js/lib/moment.min.js +0 -6
  52. data/lib/simple_metrics/public/js/lib/rickshaw.min.js +0 -1
  53. data/lib/simple_metrics/public/js/lib/underscore-1.3.1.min.js +0 -31
  54. data/lib/simple_metrics/public/js/models/graph.js +0 -6
  55. data/lib/simple_metrics/public/js/models/metric.js +0 -7
  56. data/lib/simple_metrics/public/js/router.js +0 -42
  57. data/lib/simple_metrics/public/js/views/app.js +0 -18
  58. data/lib/simple_metrics/public/js/views/dashboard.js +0 -10
  59. data/lib/simple_metrics/public/js/views/graph.js +0 -101
  60. data/lib/simple_metrics/public/js/views/metric.js +0 -82
  61. data/lib/simple_metrics/public/js/views/metrics.js +0 -10
  62. data/lib/simple_metrics/repository.rb +0 -34
  63. data/lib/simple_metrics/udp_server.rb +0 -81
  64. data/lib/simple_metrics/views/graph.erb +0 -93
  65. data/lib/simple_metrics/views/index.erb +0 -0
  66. data/lib/simple_metrics/views/layout.erb +0 -138
  67. data/lib/simple_metrics/views/show.erb +0 -31
  68. data/spec/data_point_repository_spec.rb +0 -77
  69. data/spec/importer_spec.rb +0 -126
  70. data/spec/metric_repository_spec.rb +0 -53
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+ require "eventmachine"
3
+
4
+ module SimpleMetrics
5
+
6
+ module ClientHandler
7
+
8
+ @@data_points = []
9
+
10
+ class << self
11
+ def get_and_clear_data_points
12
+ data_points = @@data_points.dup
13
+ @@data_points = []
14
+ data_points
15
+ end
16
+ end
17
+
18
+ def data_points
19
+ @@data_points
20
+ end
21
+
22
+ def post_init
23
+ SimpleMetrics.logger.info "ClientHandler entering post_init"
24
+ end
25
+
26
+ def receive_data(data)
27
+ SimpleMetrics.logger.debug "received_data: #{data.inspect}"
28
+
29
+ @@data_points ||= []
30
+ @@data_points << DataPoint.parse(data)
31
+ rescue DataPoint::ParserError => e
32
+ SimpleMetrics.logger.debug "Invalid Data skipped: #{data}"
33
+ end
34
+ end
35
+
36
+ class Server
37
+
38
+ attr_reader :db, :connection
39
+
40
+ def start
41
+ SimpleMetrics.logger.info "SERVER: starting up on #{SimpleMetrics.config[:host]}:#{SimpleMetrics.config[:port]}..."
42
+
43
+ Mongo.ensure_collections_exist
44
+
45
+ EM.run do
46
+ EM.open_datagram_socket(SimpleMetrics.config[:host], SimpleMetrics.config[:port], SimpleMetrics::ClientHandler) do |con|
47
+ EventMachine::add_periodic_timer(SimpleMetrics.config[:flush_interval]) do
48
+ SimpleMetrics.logger.debug "SERVER: period timer triggered after #{SimpleMetrics.config[:flush_interval]} seconds"
49
+
50
+ EM.defer { Bucket.flush_data_points(ClientHandler.get_and_clear_data_points) }
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ def stop
57
+ SimpleMetrics.logger.info "EventMachine stop"
58
+ EM.stop
59
+ end
60
+
61
+ def to_s
62
+ "#{SimpleMetrics.config[:host]}:#{SimpleMetrics.config[:port]}"
63
+ end
64
+
65
+ end
66
+ end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module SimpleMetrics
3
- VERSION = "0.3.6"
3
+ VERSION = "0.4.0"
4
4
  end
@@ -19,15 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "rake"
20
20
  s.add_development_dependency "rspec"
21
21
  s.add_development_dependency "rr"
22
- s.add_development_dependency "shotgun"
23
22
 
24
23
  s.add_dependency "eventmachine"
25
24
  s.add_dependency "daemons"
26
25
  s.add_dependency "mongo", '~> 1.6'
27
26
  s.add_dependency "bson", '~> 1.6'
28
- s.add_dependency "bson_ext", '~> 1.6'
29
- s.add_dependency "sinatra"
30
- s.add_dependency "erubis"
31
- s.add_dependency "vegas", '~> 0.1.2'
32
- s.add_dependency "json"
33
27
  end
data/spec/bucket_spec.rb CHANGED
@@ -37,17 +37,17 @@ module SimpleMetrics
37
37
 
38
38
  describe "#save" do
39
39
  before do
40
- DataPointRepository.truncate_collections
41
- DataPointRepository.ensure_collections_exist
40
+ Mongo.truncate_collections
41
+ Mongo.ensure_collections_exist
42
42
  bucket.save(stats, ts)
43
43
  end
44
44
 
45
45
  let(:stats) do
46
- DataPoint::Counter.new(:name => "key1", :value => 5)
46
+ DataPoint.create_counter(:name => "key1", :value => 5)
47
47
  end
48
48
 
49
49
  it "saves given data in bucket" do
50
- results = bucket.find_all_at_ts(ts)
50
+ results = bucket.find_all_by_name("key1")
51
51
  results.should have(1).item
52
52
  result = results.first
53
53
  result.name.should == stats.name
@@ -56,7 +56,7 @@ module SimpleMetrics
56
56
  end
57
57
 
58
58
  it "saves data in correct timestamp" do
59
- result = bucket.find_all_at_ts(ts).first
59
+ result = bucket.find_all_by_name("key1").first
60
60
  result.ts.should == ts/sec*sec
61
61
  end
62
62
 
@@ -65,33 +65,68 @@ module SimpleMetrics
65
65
  describe "finder methods" do
66
66
 
67
67
  before do
68
- DataPointRepository.truncate_collections
69
- DataPointRepository.ensure_collections_exist
68
+ Mongo.truncate_collections
69
+ Mongo.ensure_collections_exist
70
70
  end
71
71
 
72
- describe "#find_all_at_ts" do
72
+ describe "#find_all_by_name" do
73
+ it "returns all stats for given name" do
74
+ stats_same1 = DataPoint.create_counter(:name => "key1", :value => 5)
75
+ stats_same2 = DataPoint.create_counter(:name => "key1", :value => 3)
76
+ stats_different = DataPoint.create_counter(:name => "key2", :value => 3)
77
+
78
+ bucket.save(stats_same1, ts)
79
+ bucket.save(stats_same2, ts)
80
+ bucket.save(stats_different, ts)
81
+
82
+ results = bucket.find_all_by_name("key1")
83
+ results.should have(2).items
84
+ results.first.name.should == stats_same1.name
85
+ end
86
+ end
87
+
88
+ describe "#find_all_in_ts" do
73
89
  it "returns all stats in given timestamp" do
74
- stats1 = DataPoint::Counter.new(:name => "key1", :value => 5)
75
- stats2 = DataPoint::Counter.new(:name => "key2", :value => 3)
90
+ stats1 = DataPoint.create_counter(:name => "key1", :value => 5)
91
+ stats2 = DataPoint.create_counter(:name => "key2", :value => 3)
76
92
 
77
93
  bucket.save(stats1, ts)
78
94
  bucket.save(stats2, bucket.next_ts_bucket(ts))
79
95
 
80
- result1 = bucket.find_all_at_ts(ts).first
96
+ result1 = bucket.find_all_in_ts(ts).first
81
97
  result1.name.should == stats1.name
82
98
  result1.value.should == stats1.value
83
99
 
84
- result2 = bucket.find_all_at_ts(bucket.next_ts_bucket(ts)).first
100
+ result2 = bucket.find_all_in_ts(bucket.next_ts_bucket(ts)).first
85
101
  result2.name.should == stats2.name
86
102
  result2.value.should == stats2.value
87
103
  end
88
104
  end
89
105
 
90
- describe "#find_all_in_ts_range_by_wildcard" do
106
+ describe "#find_all_in_ts_by_name" do
107
+ it "returns all stats for given name and timestamp" do
108
+ stats1a = DataPoint.create_counter(:name => "key1", :value => 5)
109
+ stats1b = DataPoint.create_counter(:name => "key1", :value => 7)
110
+ stats2 = DataPoint.create_counter(:name => "key2", :value => 7)
111
+ stats1_different_ts = DataPoint.create_counter(:name => "key1", :value => 3)
112
+
113
+ bucket.save(stats1a, ts)
114
+ bucket.save(stats1b, ts)
115
+ bucket.save(stats2, ts)
116
+ bucket.save(stats1_different_ts, bucket.next_ts_bucket(ts))
117
+
118
+ results = bucket.find_all_in_ts_by_name(ts, "key1")
119
+ results.should have(2).items
120
+ results.first.name.should == "key1"
121
+ results.last.name.should == "key1"
122
+ end
123
+ end
124
+
125
+ describe "#find_all_in_ts_by_wildcard" do
91
126
  it "returns all stats for given name and timestamp" do
92
- stats1 = DataPoint::Counter.new(:name => "com.test.key1", :value => 5)
93
- stats2 = DataPoint::Counter.new(:name => "com.test.key2", :value => 7)
94
- stats_different = DataPoint::Counter.new(:name => "com.test2.key1", :value => 3)
127
+ stats1 = DataPoint.create_counter(:name => "com.test.key1", :value => 5)
128
+ stats2 = DataPoint.create_counter(:name => "com.test.key2", :value => 7)
129
+ stats_different = DataPoint.create_counter(:name => "com.test2.key1", :value => 3)
95
130
 
96
131
  from = bucket.ts_bucket(ts)
97
132
  to = from
@@ -109,7 +144,7 @@ module SimpleMetrics
109
144
 
110
145
  describe "#fill_gaps" do
111
146
  it "returns stats and fills missing gaps with null entries" do
112
- stats = DataPoint::Counter.new(:name => "com.test.key1", :value => 5)
147
+ stats = DataPoint.create_counter(:name => "com.test.key1", :value => 5)
113
148
 
114
149
  from = ts - 10
115
150
  to = ts + 10
@@ -134,5 +169,105 @@ module SimpleMetrics
134
169
  end
135
170
  end # describe "finder methods"
136
171
 
172
+ describe "#aggregate_all" do
173
+ before do
174
+ Mongo.truncate_collections
175
+ Mongo.ensure_collections_exist
176
+ end
177
+
178
+ it "aggregates all counter data points" do
179
+ stats1a = DataPoint.create_counter(:name => "key1", :value => 5)
180
+ stats1b = DataPoint.create_counter(:name => "key1", :value => 7)
181
+ stats2 = DataPoint.create_counter(:name => "key2", :value => 3)
182
+
183
+ bucket2 = Bucket[1]
184
+ ts_at_insert = bucket2.previous_ts_bucket(ts)
185
+ bucket.save(stats1a, ts_at_insert)
186
+ bucket.save(stats1b, ts_at_insert)
187
+ bucket.save(stats2, ts_at_insert)
188
+
189
+ Bucket.aggregate_all(ts)
190
+
191
+ results = bucket2.find_all_in_ts(ts_at_insert)
192
+ results.should have(2).items
193
+
194
+ key1_result = results.find {|stat| stat.name == "key1"}
195
+ key1_result.value.should == 12
196
+ key1_result.should be_counter
197
+
198
+ key2_result = results.find {|stat| stat.name == "key2"}
199
+ key2_result.value.should == 3
200
+ key2_result.should be_counter
201
+ end
202
+
203
+ it "aggregates all gauge data points" do
204
+ stats1a = DataPoint.create_gauge(:name => "key1", :value => 5)
205
+ stats1b = DataPoint.create_gauge(:name => "key1", :value => 7)
206
+ stats2 = DataPoint.create_gauge(:name => "key2", :value => 3)
207
+
208
+ bucket2 = Bucket[1]
209
+ ts_at_insert = bucket2.previous_ts_bucket(ts)
210
+ bucket.save(stats1a, ts_at_insert)
211
+ bucket.save(stats1b, ts_at_insert)
212
+ bucket.save(stats2, ts_at_insert)
213
+
214
+ Bucket.aggregate_all(ts)
215
+
216
+ results = bucket2.find_all_in_ts(ts_at_insert)
217
+ results.should have(2).items
218
+
219
+ key1_result = results.find {|stat| stat.name == "key1"}
220
+ key1_result.value.should == 6
221
+ key1_result.should be_gauge
222
+
223
+ key2_result = results.find {|stat| stat.name == "key2"}
224
+ key2_result.value.should == 3
225
+ key2_result.should be_gauge
226
+ end
227
+
228
+ end # describe "#aggregate_all"
229
+
230
+ describe "#flush_data_points" do
231
+ before do
232
+ Mongo.truncate_collections
233
+ Mongo.ensure_collections_exist
234
+
235
+ stats1 = DataPoint.create_counter(:name => "key1", :value => 5)
236
+ stats2 = DataPoint.create_counter(:name => "key1", :value => 7)
237
+ stats3 = DataPoint.create_counter(:name => "key2", :value => 3)
238
+ @stats = [stats1, stats2, stats3]
239
+ end
240
+
241
+ it "saves all stats in finest/first bucket" do
242
+ Bucket.flush_data_points(@stats)
243
+
244
+ results = bucket.find_all_in_ts(ts)
245
+ results.should have(2).items
246
+ end
247
+
248
+ it "calls aggregate_all afterwards" do
249
+ mock(Bucket).aggregate_all(ts)
250
+ Bucket.flush_data_points(@stats)
251
+ end
252
+
253
+ it "saves all stats and aggregate if duplicates found" do
254
+ Bucket.flush_data_points(@stats)
255
+
256
+ results = bucket.find_all_in_ts(ts)
257
+ results.should have(2).items
258
+ results.first.name.should == "key1"
259
+ results.last.name.should == "key2"
260
+ results.first.value == 12
261
+ results.last.value == 3
262
+ end
263
+
264
+ it "raises error if name matches but type does not" do
265
+ stats4 = DataPoint.create_gauge(:name => "key1", :value => 3)
266
+ input = @stats + [stats4]
267
+ expect { Bucket.flush_data_points(input) }.to raise_error(SimpleMetrics::DataPoint::NonMatchingTypesError)
268
+ end
269
+
270
+ end # describe "#flush_data_points"
271
+
137
272
  end
138
273
  end
@@ -54,28 +54,78 @@ module SimpleMetrics
54
54
  end
55
55
 
56
56
  it "parses increment timing with sample rate" do
57
- # TODO
58
57
  end
59
- end # describe
58
+ end
60
59
 
61
- describe "#aggregate" do
62
60
 
63
- it "aggregate counters" do
64
- key1 = DataPoint::Counter.new(:name => "key1", :value => 1)
65
- key2 = DataPoint::Counter.new(:name => "key1", :value => 3)
66
- result = DataPoint.aggregate_values([key1, key2])
61
+ describe "#aggregate" do
62
+ it "aggregates counter data points" do
63
+ stats1 = DataPoint.create_counter(:name => "key1", :value => 5)
64
+ stats2 = DataPoint.create_counter(:name => "key1", :value => 7)
65
+ result = DataPoint.aggregate([stats1, stats2])
66
+ result.value.should == 12
67
67
  result.name.should == "key1"
68
- result.value.should == 4
68
+ result.should be_counter
69
+ end
70
+
71
+ it "aggregates counter data points with custom name" do
72
+ stats1 = DataPoint.create_counter(:name => "key1", :value => 5)
73
+ stats2 = DataPoint.create_counter(:name => "key1", :value => 7)
74
+ result = DataPoint.aggregate([stats1, stats2], "new_name")
75
+ result.value.should == 12
76
+ result.name.should == "new_name"
77
+ result.should be_counter
69
78
  end
70
79
 
71
- it "aggregate gauges" do
72
- key1 = DataPoint::Gauge.new(:name => "key1", :value => 1)
73
- key2 = DataPoint::Gauge.new(:name => "key1", :value => 3)
74
- result = DataPoint.aggregate_values([key1, key2])
80
+ it "aggregates gauge data points" do
81
+ stats1 = DataPoint.create_gauge(:name => "key1", :value => 5)
82
+ stats2 = DataPoint.create_gauge(:name => "key1", :value => 7)
83
+ result = DataPoint.aggregate([stats1, stats2])
84
+ result.value.should == 6
75
85
  result.name.should == "key1"
76
- result.value.should == 2
86
+ result.should be_gauge
77
87
  end
78
88
 
79
- end # describe
89
+ it "aggregates timing data points" do
90
+ end
91
+
92
+ it "aggregates event data points" do
93
+ end
94
+ end
95
+
96
+ describe "#aggregate_array" do
97
+ it "aggregates counter data points" do
98
+ stats1 = DataPoint.create_counter(:name => "com.test.key1", :value => 5, :ts => ts)
99
+ stats2 = DataPoint.create_counter(:name => "com.test.key1", :value => 7, :ts => ts)
100
+ stats3 = DataPoint.create_counter(:name => "com.test.key1", :value => 9, :ts => (ts + 60) )
101
+
102
+ results = DataPoint.aggregate_array([stats1, stats2, stats3], "com.test.*")
103
+ results.should have(2).data_points
104
+ results.first.name.should == "com.test.*"
105
+ results.last.name.should == "com.test.*"
106
+ results.first.value.should == 12
107
+ results.last.value.should == 9
108
+ end
109
+
110
+ it "aggregates gauge data points" do
111
+ stats1 = DataPoint.create_gauge(:name => "com.test.key1", :value => 5, :ts => ts)
112
+ stats2 = DataPoint.create_gauge(:name => "com.test.key1", :value => 7, :ts => ts)
113
+ stats3 = DataPoint.create_gauge(:name => "com.test.key1", :value => 9, :ts => (ts + 60) )
114
+
115
+ results = DataPoint.aggregate_array([stats1, stats2, stats3], "com.test.*")
116
+ results.should have(2).data_points
117
+ results.first.name.should == "com.test.*"
118
+ results.last.name.should == "com.test.*"
119
+ results.first.value.should == 6
120
+ results.last.value.should == 9
121
+ end
122
+
123
+ it "raises NonMatchingTypesError if types are different" do
124
+ stats1 = DataPoint.create_counter(:name => "com.test.key1", :value => 5, :ts => ts)
125
+ stats2 = DataPoint.create_gauge(:name => "com.test.key1", :value => 5, :ts => ts)
126
+ expect { DataPoint.aggregate_array([stats1, stats2], "com.test.*") }.to raise_error(SimpleMetrics::DataPoint::NonMatchingTypesError)
127
+ end
128
+ end
80
129
  end
130
+
81
131
  end
data/spec/graph_spec.rb CHANGED
@@ -14,14 +14,14 @@ module SimpleMetrics
14
14
  end
15
15
 
16
16
  before do
17
- DataPointRepository.truncate_collections
18
- DataPointRepository.ensure_collections_exist
17
+ Mongo.truncate_collections
18
+ Mongo.ensure_collections_exist
19
19
  end
20
20
 
21
21
  describe "#query" do
22
22
 
23
23
  it "returns string request data points as is" do
24
- dp1 = DataPoint::Counter.new(:name => "key1", :value => 5)
24
+ dp1 = DataPoint.create_counter(:name => "key1", :value => 5)
25
25
 
26
26
  bucket.save(dp1, ts)
27
27
 
@@ -34,7 +34,7 @@ module SimpleMetrics
34
34
  end
35
35
 
36
36
  it "returns string request data points and fill graps" do
37
- dp1 = DataPoint::Counter.new(:name => "key1", :value => 5)
37
+ dp1 = DataPoint.create_counter(:name => "key1", :value => 5)
38
38
 
39
39
  bucket.save(dp1, ts)
40
40
 
@@ -49,8 +49,8 @@ module SimpleMetrics
49
49
  end
50
50
 
51
51
  it "returns wildcard request data points with aggregate counter" do
52
- dp1 = DataPoint::Counter.new(:name => "com.test.key1", :value => 5)
53
- dp2 = DataPoint::Counter.new(:name => "com.test.key2", :value => 7)
52
+ dp1 = DataPoint.create_counter(:name => "com.test.key1", :value => 5)
53
+ dp2 = DataPoint.create_counter(:name => "com.test.key2", :value => 7)
54
54
 
55
55
  bucket.save(dp1, ts)
56
56
  bucket.save(dp2, ts)
@@ -66,35 +66,24 @@ module SimpleMetrics
66
66
  result.should be_counter
67
67
  end
68
68
 
69
- end # descibe
69
+ it "returns regexp request data points with aggregate gauge" do
70
+ dp1 = DataPoint.create_gauge(:name => "com.test.key1", :value => 5)
71
+ dp2 = DataPoint.create_gauge(:name => "com.test.key2", :value => 7)
70
72
 
71
- describe "#query_all" do
72
-
73
- it "returns request data points as is" do
74
- dp1 = DataPoint::Counter.new(:name => "com.test.key1", :value => 5)
75
- dp2 = DataPoint::Counter.new(:name => "com.test.key2", :value => 7)
76
- dp3 = DataPoint::Counter.new(:name => "com.test.key2", :value => 3)
77
- bucket.save(dp1, ts)
78
- bucket.save(dp2, ts - 10)
79
- bucket.save(dp3, ts)
73
+ bucket.save(dp1, ts)
74
+ bucket.save(dp2, ts)
80
75
 
81
76
  current_ts = bucket.ts_bucket(ts)
82
- from = current_ts - 10
77
+ from = current_ts
83
78
  to = current_ts
84
- results = Graph.query_all(bucket, from, to, "com.test.key1", "com.test.key2")
85
- key1 = results.first
86
- key1[:name].should == "com.test.key1"
87
- key1[:data].should have(2).entry
88
- key1[:data].first[:y].should == 0
89
- key1[:data].last[:y].should == 5
90
-
91
- key2 = results.last
92
- key2[:name].should == "com.test.key2"
93
- key2[:data].should have(2).entry
94
- key2[:data].first[:y].should == 7
95
- key2[:data].last[:y].should == 3
96
- end
97
79
 
80
+ results = Graph.query(bucket, from, to, /com\.test(.*)/)
81
+ results.should have(1).data_point
82
+ result = results.first
83
+ result.name.should == "/com\\.test(.*)/"
84
+ result.value.should == 6
85
+ result.should be_gauge
86
+ end
98
87
  end
99
88
  end
100
89
  end