Module: Capistrano::Configuration::Execution
- Defined in:
- lib/capistrano/datadog/v2.rb
Instance Method Summary collapse
-
#find_and_execute_task(path, hooks = {}) ⇒ Object
Attempts to locate the task at the given fully-qualified path, and execute it.
Instance Method Details
#find_and_execute_task(path, hooks = {}) ⇒ Object
Attempts to locate the task at the given fully-qualified path, and execute it. If no such task exists, a Capistrano::NoSuchTaskError will be raised. Also, capture the time the task took to execute, and the logs it outputted for submission to Datadog
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/capistrano/datadog/v2.rb', line 15 def find_and_execute_task(path, hooks = {}) task = find_task(path) or raise NoSuchTaskError, "the task `#{path}' does not exist" result = nil reporter = Capistrano::Datadog.reporter task_name = task.fully_qualified_name timing = Benchmark.measure(task_name) do # Set the current task so that the logger knows which task to # associate the logs with reporter.current_task = task_name trigger(hooks[:before], task) if hooks[:before] result = execute_task(task) trigger(hooks[:after], task) if hooks[:after] reporter.current_task = nil end # Record the task name, its timing and roles roles = task.[:roles] if roles.is_a? Proc roles = roles.call end reporter.record_task(task_name, timing.real, roles, task.namespace.variables[:stage], fetch(:application)) # Return the original result result end |