summaryrefslogtreecommitdiff
path: root/lib/chef/data_collector/resource_report.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/data_collector/resource_report.rb')
-rw-r--r--lib/chef/data_collector/resource_report.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/chef/data_collector/resource_report.rb b/lib/chef/data_collector/resource_report.rb
index 1793fe2c9d..f3e272b0fb 100644
--- a/lib/chef/data_collector/resource_report.rb
+++ b/lib/chef/data_collector/resource_report.rb
@@ -22,13 +22,14 @@ class Chef
class DataCollector
class ResourceReport
- attr_reader :action, :current_resource, :elapsed_time, :new_resource, :status
- attr_accessor :conditional, :exception
+ attr_reader :action, :elapsed_time, :new_resource, :status
+ attr_accessor :conditional, :current_resource, :exception
def initialize(new_resource, action, current_resource = nil)
@new_resource = new_resource
@action = action
@current_resource = current_resource
+ @status = "unprocessed"
end
def skipped(conditional)
@@ -54,6 +55,10 @@ class Chef
@elapsed_time = new_resource.elapsed_time
end
+ def elapsed_time_in_milliseconds
+ elapsed_time.nil? ? nil : (elapsed_time * 1000).to_i
+ end
+
def to_hash
hash = {
"type" => new_resource.resource_name.to_sym,
@@ -61,7 +66,7 @@ class Chef
"id" => new_resource.identity.to_s,
"after" => new_resource.state_for_resource_reporter,
"before" => current_resource ? current_resource.state_for_resource_reporter : {},
- "duration" => (elapsed_time * 1000).to_i.to_s,
+ "duration" => elapsed_time_in_milliseconds.to_s,
"delta" => new_resource.respond_to?(:diff) ? new_resource.diff : "",
"result" => action.to_s,
"status" => status,