lib/bolt/executor.rb in bolt-1.14.0 vs lib/bolt/executor.rb in bolt-1.15.0

- old
+ new

@@ -1,11 +1,10 @@ # frozen_string_literal: true # Used for $ERROR_INFO. This *must* be capitalized! require 'English' require 'json' -require 'concurrent' require 'logging' require 'set' require 'bolt/analytics' require 'bolt/result' require 'bolt/config' @@ -23,14 +22,17 @@ def initialize(concurrency = 1, analytics = Bolt::Analytics::NoopClient.new, noop = nil, bundled_content: nil, load_config: true) + + # lazy-load expensive gem code + require 'concurrent' + @analytics = analytics @bundled_content = bundled_content @logger = Logging.logger[self] - @plan_logging = false @load_config = load_config @transports = Bolt::TRANSPORTS.each_with_object({}) do |(key, val), coll| coll[key.to_s] = if key == :remote Concurrent::Delay.new do @@ -195,9 +197,25 @@ # Intentionally rounded to an integer. High precision isn't useful. data[:resource_mean] = sum / resource_counts.length end @analytics&.event('Apply', 'ast', data) + end + + def report_yaml_plan(plan) + steps = plan.steps.count + return_type = case plan.return + when Bolt::PAL::YamlPlan::EvaluableString + 'expression' + when nil + nil + else + 'value' + end + + @analytics&.event('Plan', 'yaml', plan_steps: steps, return_type: return_type) + rescue StandardError => e + @logger.debug { "Failed to submit analytics event: #{e.message}" } end def with_node_logging(description, batch) @logger.info("#{description} on #{batch.map(&:uri)}") result = yield