Permalink
Browse files

add queue-specific metrics and update the readme

  • Loading branch information...
1 parent 573c0be commit 833e8d2cd77e7a97a5c385a1955c2274987cecd4 Sven Fuchs committed Aug 1, 2012
Showing with 48 additions and 10 deletions.
  1. +16 −0 README.md
  2. +12 −4 lib/travis/event/handler/metrics.rb
  3. +20 −6 spec/travis/event/handler/metrics_spec.rb
View
@@ -66,6 +66,22 @@ $ bundle exec rake
Enqueues queueable jobs based on a per-owner rate limit.
+* `v1.job.queue.wait\_time`
+
+ Time jobs wait in the queue before being started (i.e. job.created_at to job.started_at)
+
+* `v1.job.queue.wait\_time.[queue\_name]`
+
+ (same, but per queue)
+
+* `v1.job.queue.duration`
+
+ Time jobs take for being run (i.e. job.started_at to job.finished_at)
+
+* `v1.job.duration.[queue\_name]`
+
+ (same, but per queue)
+
* `v1.travis.event.handler.\*.notify`
Responds to `build:finished` events and creates an instance of `Task::Archive`.
@@ -13,16 +13,24 @@ def handle?
def handle
case event
when 'job:test:started'
- meter('job.queue.wait_time', object.created_at, object.started_at)
+ events = %W(job.queue.wait_time job.queue.wait_time.#{queue})
+ meter(events, object.created_at, object.started_at)
when 'job:test:finished'
- meter('job.duration', object.started_at, object.finished_at)
+ events = %W(job.duration job.duration.#{queue})
+ meter(events, object.started_at, object.finished_at)
end
end
private
- def meter(event, started_at, finished_at)
- Travis::Instrumentation.meter(event, :started_at => started_at, :finished_at => finished_at)
+ def queue
+ object.queue.gsub('.', '-')
+ end
+
+ def meter(events, started_at, finished_at)
+ events.each do |event|
+ Travis::Instrumentation.meter(event, :started_at => started_at, :finished_at => finished_at)
+ end
end
end
end
@@ -42,14 +42,28 @@ def notify(event, object)
Travis::Event::Handler::Metrics.new(event, object).notify
end
- it 'job:test:started notifies' do
- Travis::Instrumentation.expects(:meter).with('job.queue.wait_time', :started_at => created_at, :finished_at => started_at)
- notify('job:test:started', test)
+ describe 'job:test:started' do
+ it 'meters on job.queue.wait_time' do
+ Travis::Instrumentation.expects(:meter).with('job.queue.wait_time', :started_at => created_at, :finished_at => started_at)
+ notify('job:test:started', test)
+ end
+
+ it 'meters on job.queue.builds-common.wait_time' do
+ Travis::Instrumentation.expects(:meter).with('job.queue.wait_time.builds-common', :started_at => created_at, :finished_at => started_at)
+ notify('job:test:started', test)
+ end
end
- it 'job:test:finished notifies' do
- Travis::Instrumentation.expects(:meter).with('job.duration', :started_at => started_at, :finished_at => finished_at)
- notify('job:test:finished', test)
+ describe 'job:test:finished' do
+ it 'meters on job.duration' do
+ Travis::Instrumentation.expects(:meter).with('job.duration', :started_at => started_at, :finished_at => finished_at)
+ notify('job:test:finished', test)
+ end
+
+ it 'meters on job.duration' do
+ Travis::Instrumentation.expects(:meter).with('job.duration.builds-common', :started_at => started_at, :finished_at => finished_at)
+ notify('job:test:finished', test)
+ end
end
end
end

0 comments on commit 833e8d2

Please sign in to comment.