Skip to content

Commit

Permalink
(puppetlabsGH-2840) Report whether tasks are run in noop mode
Browse files Browse the repository at this point in the history
This adds a new analytics event that reports whether or not a task is
run in no-operation mode.

!feature

* **Report whether tasks are run in no-operation mode**
  ([puppetlabs#2840](puppetlabs#2840))

  Bolt now reports whether or not a task is run in no-operation mode
  when it collects analytics.
  • Loading branch information
beechtom committed Jun 1, 2021
1 parent 339083b commit 0927ac5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bolt-modules/boltlib/lib/puppet/functions/run_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def run_task_with_description(task_name, targets, description, args = {})
end
end

# Report whether the task was run in noop mode.
executor.report_noop_mode(executor.noop || options[:noop])

if targets.empty?
Bolt::ResultSet.new([])
else
Expand Down
3 changes: 3 additions & 0 deletions bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def run_task_with_with_description(task_name, targets, description, options = {}
end
end

# Report whether the task was run in noop mode.
executor.report_noop_mode(executor.noop || options[:noop])

if targets.empty?
Bolt::ResultSet.new([])
else
Expand Down
1 change: 1 addition & 0 deletions documentation/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ with a randomly generated, non-identifiable user UUID:
- IDs of any deprecation warnings
- Whether the source file for `upload_file`, `run_script`, or `file::read` plan
functions uses an absolute path or a module path.
- Whether a task is run in no-operation mode.
## Viewing collected data
Expand Down
4 changes: 4 additions & 0 deletions lib/bolt/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ def report_file_source(plan_function, source)
@analytics&.event('Plan', plan_function, label: label)
end

def report_noop_mode(noop)
@analytics&.event('Task', 'noop', label: (!!noop).to_s)
end

def report_apply(statement_count, resource_counts)
data = { statement_count: statement_count }

Expand Down
2 changes: 2 additions & 0 deletions lib/bolt_spec/plans/mock_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def report_apply(_statements, _resources); end

def report_yaml_plan(_plan); end

def report_noop_mode(_mode); end

def shutdown; end

def start_plan(_plan_context); end
Expand Down

0 comments on commit 0927ac5

Please sign in to comment.