namespace :appsignal do task :deploy do appsignal_env = fetch(:appsignal_env, fetch(:stage, fetch(:rails_env, fetch(:rack_env, "production")))) user = fetch(:appsignal_user, ENV["USER"] || ENV["USERNAME"]) revision = fetch(:appsignal_revision, fetch(:current_revision)) appsignal_config = Appsignal::Config.new( ENV["PWD"], appsignal_env, {}, Logger.new(StringIO.new) ).tap do |c| fetch(:appsignal_config, {}).each do |key, value| c[key] = value end c.validate end if appsignal_config && appsignal_config.active? marker_data = { :revision => revision, :user => user } marker = Appsignal::Marker.new(marker_data, appsignal_config) # {#dry_run?} helper was added in Capistrano 3.5.0 # https://github.com/capistrano/capistrano/commit/38d8d6d2c8485f1b5643857465b16ff01da57aff if respond_to?(:dry_run?) && dry_run? puts "Dry run: AppSignal deploy marker not actually sent." else marker.transmit end else puts "Not notifying of deploy, config is not active for environment: #{appsignal_env}" end end end after "deploy:finished", "appsignal:deploy"