Skip to content

Commit

Permalink
add the started_at as well and then work out the duration when requested
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk committed Sep 23, 2012
1 parent 5709129 commit fbb9222
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/travis/notification/instrument.rb
Expand Up @@ -41,16 +41,20 @@ def publish(message, status, args, method)
async :publish, :queue => :instrumentation
end

attr_reader :config, :target, :result, :exception, :finished_at, :message, :status
attr_reader :config, :target, :result, :exception, :started_at, :finished_at, :message, :status

def initialize(message, status, payload)
@target, @result, @exception = payload.values_at(:target, :result, :exception)
@finished_at = payload[:finished_at]
@started_at, @finished_at = payload.values_at(:started_at, :finished_at)
@config = { :message => message }
@config[:exception] = exception if exception
@status = status.to_sym
end

def duration
@duration ||= (finished_at ? finished_at - started_at : nil)
end

private

def publish(event = {})
Expand Down

0 comments on commit fbb9222

Please sign in to comment.