lib/instrumental/capistrano.rb in instrumental_agent-0.7.1 vs lib/instrumental/capistrano.rb in instrumental_agent-0.7.2

- old
+ new

@@ -5,29 +5,31 @@ Capistrano::Configuration.instance.load do namespace :instrumental do namespace :util do desc "marker for beginning of deploy" task :deploy_start do - @instrumental_deploy_start = Time.now + set :instrumental_deploy_start, Time.now end desc "marker for end of deploy" task :deploy_end do - @instrumental_deploy_end = Time.now + set :instrumental_deploy_end, Time.now end end desc "send a notice to instrumental about the deploy" task :record_deploy_notice do - @instrumental_deploy_start ||= Time.now - @instrumental_deploy_end ||= Time.now - deploy_duration_in_seconds = (@instrumental_deploy_end - @instrumental_deploy_start).to_i + start_at = exists?(:instrumental_deploy_start) ? instrumental_deploy_start : Time.now + end_at = exists?(:instrumental_deploy_end) ? instrumental_deploy_end : start_at + puts "@instrumental_deploy_start = #{start_at.inspect}" + puts "@instrumental_deploy_end = #{end_at.inspect}" + deploy_duration_in_seconds = end_at - start_at deployer = Etc.getlogin.chomp agent_options = { :synchronous => true } agent_options[:collector] = instrumental_host if exists?(:instrumental_host) agent = Instrumental::Agent.new(instrumental_key, agent_options) agent.notice("#{deployer} deployed #{current_revision}", - @instrumental_deploy_start, + start_at, deploy_duration_in_seconds) logger.info("Notified Instrumental of deployment") end end