Deployer & Tideways Deployment Events
For a few of our customer projects, we use Tideways to spot performance bottlenecks and get real-time error detection alerts.
As a bonus, Tideways can track deployment events to compare performance and failure rates before and after the deployment.
The following steps cover how I integrated the Tideways deployment events notifications into our Deployer workflow. In this particular project, we are still using Deploye 6.8, if you are using a newer version of Deployer, you might need to adapt a few things.
First, let's define the Tideways configuration options. Mainly, the Tideways url as well as the API key that we need to authenticate against the Tideways API:
set('tideways_webhook', 'https://app.tideways.io/api/events');
set('tideways_api_key', '123456789');
The main logic is defined in the tideways:release
task, which will post the needed information to the Tideways API:
task('tideways:release', function () {
// $target will either be production or staging, depending on the deployment stage
$target = get('target');
$tag = 'Release '.$target;
if (input()->hasOption('tag')) {
$tag = input()->getOption('tag');
}
// send POST request to the Tideways API
Httpie::post(get('tideways_webhook'))->body([
'apiKey' => get('tideways_api_key'),
'name' => $tag,
'environment' => $target,
'type' => 'release'
])->send();
})
->once()
->shallow();
The minimum information Tideways needs is apiKey
, name
, and type
. The apiKey
field contains the key we defined above, which authenticates us against the Tideways API.
The name
field contains the release's name so that we can identify it in the Tideways graph. I decided to use the Git tag, which gets deployed as the name. The type
field can either be set to release
or marker
. I decided to go with release
.
To make sure the marker gets added to the environment we have deployed to, the target
field gets set, which contains either production
or staging
.
And last but not least, we need to let Deployer know that the tideways:release
task should run after a successful deployment:
after('success', 'tideways:release');
And this is how the release marker looks like in the Tideways Graph after a successful deployment: