rearview 1.0.3.rc.2-jruby → 1.0.3.rc.3-jruby
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/rearview/job.rb +11 -0
- data/lib/rearview/stats_service.rb +4 -0
- data/lib/rearview/stats_task.rb +2 -1
- data/lib/rearview/statsd.rb +10 -0
- data/lib/rearview/version.rb +1 -1
- data/spec/dummy/log/development.log +72 -0
- data/spec/dummy/log/test.log +10661 -0
- data/spec/lib/rearview/stats_service_spec.rb +14 -0
- data/spec/lib/rearview/stats_task_spec.rb +1 -1
- data/spec/lib/rearview/statsd_spec.rb +24 -5
- data/spec/models/job_spec.rb +16 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d18574480d2cb164b05a399d03d8471f0a2eb86
|
4
|
+
data.tar.gz: 536a96e7c77dbdd0249713fa36fcd2e5b1a54cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7894d65ca93d5e9ffd6b9a82e325b21a267806bc7a83ade90883063c8150a8a450a5bfe5f04629d0fd0652a4e1eca58e04bf58fcbc2bc09f2f576e87b826916
|
7
|
+
data.tar.gz: eec2f7f6dbb2f9a290534408c6cc8faa5d3e2281934f7f87f466f97acc54b3a133ede123a17b6ec22dc387e44727d3ed5fd178728f8356aca291b378c1bd1de6
|
data/app/models/rearview/job.rb
CHANGED
@@ -140,6 +140,7 @@ module Rearview
|
|
140
140
|
|
141
141
|
def create_associated_event(transition)
|
142
142
|
logger.debug "#{self}#create_associated_event for transition #{transition.inspect}"
|
143
|
+
report_transition(transition)
|
143
144
|
job_error_attrs = {}
|
144
145
|
job_error_attrs.merge!(event_data[:job_error]) if event_data.try(:[],:job_error)
|
145
146
|
job_error = job_errors.create(job_error_attrs)
|
@@ -148,6 +149,7 @@ module Rearview
|
|
148
149
|
|
149
150
|
def update_associated_event(transition)
|
150
151
|
logger.debug "#{self}#update_associated_event for transition #{transition.inspect}"
|
152
|
+
report_transition(transition)
|
151
153
|
job_error = Rearview::JobError.latest_entry(self)
|
152
154
|
if job_error.present?
|
153
155
|
job_error.fire_event(translate_associated_event(transition),event_data)
|
@@ -156,6 +158,15 @@ module Rearview
|
|
156
158
|
|
157
159
|
protected
|
158
160
|
|
161
|
+
def report_transition(transition)
|
162
|
+
Rearview::Statsd.report do |stats|
|
163
|
+
metric = ( transition.event.to_s == 'success' ? 'success' : 'failure' )
|
164
|
+
stats.increment("monitor.#{metric}")
|
165
|
+
end
|
166
|
+
rescue
|
167
|
+
logger.error "#{self} report_transition failed: #{$!}\n#{$@.join("\n")}"
|
168
|
+
end
|
169
|
+
|
159
170
|
def translate_associated_event(transition)
|
160
171
|
if transition.event.to_s == Status::SECURITY_ERROR
|
161
172
|
:error
|
data/lib/rearview/stats_task.rb
CHANGED
@@ -15,7 +15,7 @@ module Rearview
|
|
15
15
|
# safest max UDP message size is 512.
|
16
16
|
#
|
17
17
|
# So make sure that batch_size * 8bytes/per int < 512
|
18
|
-
@statsd.batch_size =
|
18
|
+
@statsd.batch_size = 12
|
19
19
|
schedule if start
|
20
20
|
end
|
21
21
|
|
@@ -39,6 +39,7 @@ module Rearview
|
|
39
39
|
batch.gauge('vm.non_heap.init',vm.non_heap.init.bytes_to_kilobytes)
|
40
40
|
batch.gauge('vm.non_heap.max',vm.non_heap.max.bytes_to_kilobytes)
|
41
41
|
batch.gauge('vm.non_heap.used',vm.non_heap.used.bytes_to_kilobytes)
|
42
|
+
batch.gauge('monitor.total',( Rearview.config.monitor_enabled? ? Rearview.monitor_service.jobs.keys.count : 0 ))
|
42
43
|
end
|
43
44
|
rescue
|
44
45
|
error "#{self} run failed: #{$!}\n#{$@.join("\n")}"
|
data/lib/rearview/statsd.rb
CHANGED
@@ -6,6 +6,16 @@ module Rearview
|
|
6
6
|
self.namespace = Rearview.config.statsd_connection[:namespace]
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.statsd
|
10
|
+
@@statsd ||= Rearview::Statsd.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.report
|
14
|
+
if block_given? && Rearview.config.stats_enabled?
|
15
|
+
yield self.statsd
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
9
19
|
end
|
10
20
|
end
|
11
21
|
|
data/lib/rearview/version.rb
CHANGED
@@ -239,3 +239,75 @@
|
|
239
239
|
[1m[35m (13.0ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
240
240
|
[1m[36m (2.0ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
241
241
|
[1m[35m (2.0ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20131106162900')
|
242
|
+
[1m[36m (88.0ms)[0m [1mDROP DATABASE IF EXISTS `rearview_ruby_test`[0m
|
243
|
+
[1m[35m (7.0ms)[0m CREATE DATABASE `rearview_ruby_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
|
244
|
+
[1m[36m (66.0ms)[0m [1mCREATE TABLE `applications` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255) NOT NULL, `created_at` datetime, `updated_at` datetime, `deleted_at` datetime, `ancestry` varchar(255), `description` varchar(255)) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
245
|
+
[1m[35m (18.0ms)[0m CREATE INDEX `index_applications_on_ancestry` ON `applications` (`ancestry`)
|
246
|
+
[1m[36m (14.0ms)[0m [1mCREATE INDEX `user_id` ON `applications` (`user_id`)[0m
|
247
|
+
[1m[35m (14.0ms)[0m CREATE TABLE `job_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11) DEFAULT 0 NOT NULL, `created_at` datetime, `updated_at` datetime, `data` longtext NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
248
|
+
[1m[36m (9.0ms)[0m [1mCREATE TABLE `job_errors` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11), `created_at` datetime, `message` longtext, `status` varchar(255), `last_alerted_at` datetime, `updated_at` datetime) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
249
|
+
[1m[35m (9.0ms)[0m CREATE INDEX `job_id` ON `job_errors` (`job_id`)
|
250
|
+
[1m[36m (18.0ms)[0m [1mCREATE TABLE `jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `name` varchar(255) NOT NULL, `active` tinyint(1) DEFAULT 1 NOT NULL, `last_run` datetime, `cron_expr` varchar(1024) NOT NULL, `status` varchar(255), `user_id` int(11), `alert_keys` text, `deleted_at` datetime, `error_timeout` int(11) DEFAULT 60 NOT NULL, `next_run` datetime, `description` text, `app_id` int(11) NOT NULL, `metrics` text NOT NULL, `monitor_expr` text, `minutes` int(11), `to_date` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
251
|
+
[1m[35m (11.0ms)[0m CREATE INDEX `app_id` ON `jobs` (`app_id`)
|
252
|
+
[1m[36m (12.0ms)[0m [1mCREATE UNIQUE INDEX `id_name_version_key` ON `jobs` (`id`, `name`)[0m
|
253
|
+
[1m[35m (17.0ms)[0m CREATE INDEX `jobs_ibfk_1` ON `jobs` (`user_id`)
|
254
|
+
[1m[36m (8.0ms)[0m [1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `email` varchar(255) NOT NULL, `first_name` varchar(255), `last_name` varchar(255), `last_login` datetime, `preferences` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
255
|
+
[1m[35m (10.0ms)[0m CREATE UNIQUE INDEX `email` ON `users` (`email`)
|
256
|
+
[1m[36m (16.0ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
257
|
+
[1m[35m (13.0ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
258
|
+
[1m[36m (4.0ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
259
|
+
[1m[35m (3.0ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20131106162900')
|
260
|
+
[1m[36m (8.0ms)[0m [1mDROP DATABASE IF EXISTS `rearview_ruby_test`[0m
|
261
|
+
[1m[35m (1.0ms)[0m CREATE DATABASE `rearview_ruby_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
|
262
|
+
[1m[36m (16.0ms)[0m [1mCREATE TABLE `applications` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255) NOT NULL, `created_at` datetime, `updated_at` datetime, `deleted_at` datetime, `ancestry` varchar(255), `description` varchar(255)) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
263
|
+
[1m[35m (10.0ms)[0m CREATE INDEX `index_applications_on_ancestry` ON `applications` (`ancestry`)
|
264
|
+
[1m[36m (9.0ms)[0m [1mCREATE INDEX `user_id` ON `applications` (`user_id`)[0m
|
265
|
+
[1m[35m (10.0ms)[0m CREATE TABLE `job_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11) DEFAULT 0 NOT NULL, `created_at` datetime, `updated_at` datetime, `data` longtext NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
266
|
+
[1m[36m (8.0ms)[0m [1mCREATE TABLE `job_errors` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11), `created_at` datetime, `message` longtext, `status` varchar(255), `last_alerted_at` datetime, `updated_at` datetime) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
267
|
+
[1m[35m (9.0ms)[0m CREATE INDEX `job_id` ON `job_errors` (`job_id`)
|
268
|
+
[1m[36m (8.0ms)[0m [1mCREATE TABLE `jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `name` varchar(255) NOT NULL, `active` tinyint(1) DEFAULT 1 NOT NULL, `last_run` datetime, `cron_expr` varchar(1024) NOT NULL, `status` varchar(255), `user_id` int(11), `alert_keys` text, `deleted_at` datetime, `error_timeout` int(11) DEFAULT 60 NOT NULL, `next_run` datetime, `description` text, `app_id` int(11) NOT NULL, `metrics` text NOT NULL, `monitor_expr` text, `minutes` int(11), `to_date` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
269
|
+
[1m[35m (10.0ms)[0m CREATE INDEX `app_id` ON `jobs` (`app_id`)
|
270
|
+
[1m[36m (9.0ms)[0m [1mCREATE UNIQUE INDEX `id_name_version_key` ON `jobs` (`id`, `name`)[0m
|
271
|
+
[1m[35m (12.0ms)[0m CREATE INDEX `jobs_ibfk_1` ON `jobs` (`user_id`)
|
272
|
+
[1m[36m (15.0ms)[0m [1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `email` varchar(255) NOT NULL, `first_name` varchar(255), `last_name` varchar(255), `last_login` datetime, `preferences` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
273
|
+
[1m[35m (8.0ms)[0m CREATE UNIQUE INDEX `email` ON `users` (`email`)
|
274
|
+
[1m[36m (14.0ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
275
|
+
[1m[35m (11.0ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
276
|
+
[1m[36m (1.0ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
277
|
+
[1m[35m (2.0ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20131106162900')
|
278
|
+
[1m[36m (12.0ms)[0m [1mDROP DATABASE IF EXISTS `rearview_ruby_test`[0m
|
279
|
+
[1m[35m (1.0ms)[0m CREATE DATABASE `rearview_ruby_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
|
280
|
+
[1m[36m (42.0ms)[0m [1mCREATE TABLE `applications` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255) NOT NULL, `created_at` datetime, `updated_at` datetime, `deleted_at` datetime, `ancestry` varchar(255), `description` varchar(255)) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
281
|
+
[1m[35m (10.0ms)[0m CREATE INDEX `index_applications_on_ancestry` ON `applications` (`ancestry`)
|
282
|
+
[1m[36m (9.0ms)[0m [1mCREATE INDEX `user_id` ON `applications` (`user_id`)[0m
|
283
|
+
[1m[35m (12.0ms)[0m CREATE TABLE `job_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11) DEFAULT 0 NOT NULL, `created_at` datetime, `updated_at` datetime, `data` longtext NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
284
|
+
[1m[36m (9.0ms)[0m [1mCREATE TABLE `job_errors` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11), `created_at` datetime, `message` longtext, `status` varchar(255), `last_alerted_at` datetime, `updated_at` datetime) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
285
|
+
[1m[35m (9.0ms)[0m CREATE INDEX `job_id` ON `job_errors` (`job_id`)
|
286
|
+
[1m[36m (19.0ms)[0m [1mCREATE TABLE `jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `name` varchar(255) NOT NULL, `active` tinyint(1) DEFAULT 1 NOT NULL, `last_run` datetime, `cron_expr` varchar(1024) NOT NULL, `status` varchar(255), `user_id` int(11), `alert_keys` text, `deleted_at` datetime, `error_timeout` int(11) DEFAULT 60 NOT NULL, `next_run` datetime, `description` text, `app_id` int(11) NOT NULL, `metrics` text NOT NULL, `monitor_expr` text, `minutes` int(11), `to_date` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
287
|
+
[1m[35m (10.0ms)[0m CREATE INDEX `app_id` ON `jobs` (`app_id`)
|
288
|
+
[1m[36m (10.0ms)[0m [1mCREATE UNIQUE INDEX `id_name_version_key` ON `jobs` (`id`, `name`)[0m
|
289
|
+
[1m[35m (18.0ms)[0m CREATE INDEX `jobs_ibfk_1` ON `jobs` (`user_id`)
|
290
|
+
[1m[36m (14.0ms)[0m [1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `email` varchar(255) NOT NULL, `first_name` varchar(255), `last_name` varchar(255), `last_login` datetime, `preferences` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
291
|
+
[1m[35m (17.0ms)[0m CREATE UNIQUE INDEX `email` ON `users` (`email`)
|
292
|
+
[1m[36m (15.0ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
293
|
+
[1m[35m (11.0ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
294
|
+
[1m[36m (2.0ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
295
|
+
[1m[35m (2.0ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20131106162900')
|
296
|
+
[1m[36m (34.0ms)[0m [1mDROP DATABASE IF EXISTS `rearview_ruby_test`[0m
|
297
|
+
[1m[35m (7.0ms)[0m CREATE DATABASE `rearview_ruby_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
|
298
|
+
[1m[36m (65.0ms)[0m [1mCREATE TABLE `applications` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255) NOT NULL, `created_at` datetime, `updated_at` datetime, `deleted_at` datetime, `ancestry` varchar(255), `description` varchar(255)) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
299
|
+
[1m[35m (9.0ms)[0m CREATE INDEX `index_applications_on_ancestry` ON `applications` (`ancestry`)
|
300
|
+
[1m[36m (21.0ms)[0m [1mCREATE INDEX `user_id` ON `applications` (`user_id`)[0m
|
301
|
+
[1m[35m (27.0ms)[0m CREATE TABLE `job_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11) DEFAULT 0 NOT NULL, `created_at` datetime, `updated_at` datetime, `data` longtext NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
302
|
+
[1m[36m (16.0ms)[0m [1mCREATE TABLE `job_errors` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `job_id` int(11), `created_at` datetime, `message` longtext, `status` varchar(255), `last_alerted_at` datetime, `updated_at` datetime) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
303
|
+
[1m[35m (16.0ms)[0m CREATE INDEX `job_id` ON `job_errors` (`job_id`)
|
304
|
+
[1m[36m (23.0ms)[0m [1mCREATE TABLE `jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `name` varchar(255) NOT NULL, `active` tinyint(1) DEFAULT 1 NOT NULL, `last_run` datetime, `cron_expr` varchar(1024) NOT NULL, `status` varchar(255), `user_id` int(11), `alert_keys` text, `deleted_at` datetime, `error_timeout` int(11) DEFAULT 60 NOT NULL, `next_run` datetime, `description` text, `app_id` int(11) NOT NULL, `metrics` text NOT NULL, `monitor_expr` text, `minutes` int(11), `to_date` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
305
|
+
[1m[35m (10.0ms)[0m CREATE INDEX `app_id` ON `jobs` (`app_id`)
|
306
|
+
[1m[36m (20.0ms)[0m [1mCREATE UNIQUE INDEX `id_name_version_key` ON `jobs` (`id`, `name`)[0m
|
307
|
+
[1m[35m (17.0ms)[0m CREATE INDEX `jobs_ibfk_1` ON `jobs` (`user_id`)
|
308
|
+
[1m[36m (24.0ms)[0m [1mCREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `email` varchar(255) NOT NULL, `first_name` varchar(255), `last_name` varchar(255), `last_login` datetime, `preferences` text) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
309
|
+
[1m[35m (17.0ms)[0m CREATE UNIQUE INDEX `email` ON `users` (`email`)
|
310
|
+
[1m[36m (25.0ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8[0m
|
311
|
+
[1m[35m (12.0ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
312
|
+
[1m[36m (1.0ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
313
|
+
[1m[35m (4.0ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20131106162900')
|