Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/coursemology/evaluator/logging/docker_log_subscriber.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
class Coursemology::Evaluator::Logging::DockerLogSubscriber < ActiveSupport::LogSubscriber
def pull(event)
info "#{color("Docker Pull (#{event.duration.round(1)}ms)", GREEN)} #{event.payload[:image]}"
end

def create(event)
info "#{color("Docker Create (#{event.duration.round(1)}ms)", MAGENTA)} "\
"#{event.payload[:image]} => #{event.payload[:container].id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ def execute

def create_container(image)
image_identifier = "coursemology/evaluator-image-#{image}"
ActiveSupport::Notifications.instrument('pull.docker.evaluator.coursemology',
image: image_identifier) do
Docker::Image.create('fromImage' => image_identifier)
end

ActiveSupport::Notifications.instrument('create.docker.evaluator.coursemology',
image: image_identifier) do |payload|
Docker::Image.create('fromImage' => image_identifier)
payload[:container] = Docker::Container.create('Image' => image_identifier)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
container
end

it 'instruments the pull' do
expect { subject.send(:create_container, image) }.to \
instrument_notification('pull.docker.evaluator.coursemology')
end

it 'instruments the creation' do
expect { subject.send(:create_container, image) }.to \
instrument_notification('create.docker.evaluator.coursemology')
Expand Down