Skip to content

Commit

Permalink
Merge pull request #46 from ArjenSchwarz/feature/datadog-application-…
Browse files Browse the repository at this point in the history
…name

Report the application name as well when deploying with Capistrano
  • Loading branch information
clofresh committed May 5, 2014
2 parents 5a6976f + 957475d commit e5f4738
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/capistrano/datadog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ def initialize()
@logging_output = {}
end

def record_task(task_name, timing, roles, stage=nil)
def record_task(task_name, timing, roles, stage=nil, application_name=nil)
@tasks << {
:name => task_name,
:timing => timing,
:roles => roles,
:stage => stage
:stage => stage,
:application => application_name
}
end

Expand All @@ -80,7 +81,11 @@ def report()
if !task[:stage].nil? and !task[:stage].empty? then
tags << "#stage:#{task[:stage]}"
end
title = "%s@%s ran %s on %s with capistrano in %.2f secs" % [user, hostname, name, roles.join(', '), task[:timing]]
application = ''
if !task[:application].nil? and !task[:application].empty? then
application = ' for ' + task[:application]
end
title = "%s@%s ran %s%s on %s with capistrano in %.2f secs" % [user, hostname, name, application, roles.join(', '), task[:timing]]
type = "deploy"
alert_type = "success"
source_type = "capistrano"
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/datadog/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def find_and_execute_task(path, hooks = {})
if roles.is_a? Proc
roles = roles.call
end
reporter.record_task(task_name, timing.real, roles, task.namespace.variables[:stage])
reporter.record_task(task_name, timing.real, roles, task.namespace.variables[:stage], fetch(:application))

# Return the original result
result
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/datadog/v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def invoke(*args)
result = old_invoke(*args)
end
reporter.record_task(task_name, timing.real, roles,
Capistrano::Configuration.env.fetch(:stage))
Capistrano::Configuration.env.fetch(:stage), Capistrano::Configuration.env.fetch(:application))
result
end
end
Expand Down

0 comments on commit e5f4738

Please sign in to comment.