Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report the application name as well when deploying with Capistrano #46

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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