Reporting deploys to track improvements

How your application functions can change with each new deployment. When tracking your deploys with AppSignal, error incidents and performance measurements are grouped per deployment, so you can easily see what impacts your deployment has had on your application's performance and error rate. AppSignal can take you from an error backtrace to the line of code from which a specific error originated, and this help

This guide will show you how to track deploys in AppSignal using deploy markers.

Read more in-depth information about deploy markers and what they're used for.

Configuring AppSignal

This guide will use the revision config option method of reporting deploy markers. You can read about alternative approaches to this in our Deploy Markers documentation.

The revision config option is configured differently per integration language. See the list of integrations below for the one your app uses.

Heroku apps using the "Dyno Metadata" labs feature will automatically report a deploy.

Automatically Update the Revision

We recommend dynamically fetching the revision config option value from the source control management used for your project (such as Git or SVN) on start or deploy. This way, the value doesn't have to be manually updated per deploy. If a Git commit hash is used, it will also be compatible with error backtrace links.

Below is an example of how you would do this using Git:

bash
git log --pretty=format:'%h' -n 1 # Will output the current commit's short SHA

We'll continue to use Git for all integration examples in this documentation.

Configurations per Language

Ruby

For Ruby applications we will load the Git revision in the config/appsignal.yml config file. The config file is interpreted as an ERB (Embedded Ruby) template, which allows us to run arbitrary code in it.

The shell command that we run in the revision configuration option in ERB is the same command we used previously to retrieve the hash of the current commit. Using ERB, we call the git log command and set the output as the revision config option, as shown in the example below:

yaml
# Example: config/appsignal.yml production: revision: "<%= `git log --pretty=format:'%h' -n 1` %>" # Other config options

Using Ruby deploy gems

If you use a deployment tool like Capistrano or Hatchbox that excludes the .git folder from getting deployed:

  • Modify the deploy process to run a command that creates a REVISION file in the current folder which contains the Git hash: git log --pretty=format:'%h' -n 1 > REVISION

When using a Platform-as-a-Service provider, the provider might create this file for you, or expose the revision as an environment variable that you can read from the configuration file. If you are unsure if this applies to you, check with your provider or get in touch, we may know the answer.

Below is an example of how to read the Git hash from a REVISION file when using Rails:

yaml
# Example: config/appsignal.yml production: <% revision = if (defined?(Rails)); Rails.root.join('REVISION'); end %> <% if revision&.exist? %> revision: "<%= revision.read.strip[0, 7] %>" <% end %>

Read more about Ruby revision configuration option details

Elixir

For Elixir applications we will load the Git revision in the config/appsignal.exs config file (your file location may differ).

In the example config/appsignal.exs file below, we call the git log command with Elixir and set the output as the revision config option.

elixir
# Example: config/appsignal.exs {revision, _exitcode} = System.cmd("git", ["log", "--pretty=format:%h", "-n 1"]) config :appsignal, :config, revision: revision # Other config options

Read more about Elixir revision configuration option details

Node.js

For Node.js applications, the Git revision is loaded in the app's config file.

In the below .js snippet we call the git log command with Node.js and set the output as the revision config option.

javascript
// Example: appsignal.js const childProcess = require("child_process"); const REVISION = childProcess .execSync("git log --pretty=format:'%h' -n 1") .toString(); const appsignal = new Appsignal({ revision: REVISION, // Other config }); module.exports = { appsignal };

Read more about Node.js revision configuration option details

Python

For Python applications, the Git revision is loaded in the application's __appsignal__.py config file.

In the example below, we call the Git log command with Python and set the output as the revision config option. The shell command that we run is the same command we used previously to retrieve the hash of the current commit.

python
# Example: __appsignal__.py import subprocess from appsignal import Appsignal revision = subprocess \ .run(["git", "log", "--pretty=format:%h", "-n 1"], stdout=subprocess.PIPE) \ .stdout \ .decode("utf-8") appsignal = Appsignal( # Other config revision=revision )

Read more about the Python revision configuration option details

JavaScript

Because Front-end JavaScript applications run in-browser, it is not possible to call the git executable command from your front-end application to get the current revision. Instead you need to define the revision value in the HTML body as a property using your back-end application (such as a Ruby or Elixir application), like in the example below:

html
<body data-app-revision="REVISION VALUE"> <!-- Rest of the HTML --> </body>

We can then retrieve this value in the JavaScript, like below:

javascript
// Example: appsignal.js const body = document.body; export const appsignal = new Appsignal({ revision: body.dataset.appRevision, // Other config });

Read more about JavaScript revision configuration option details

Deploy

When finished configuring the revision option, commit your changes and deploy your application. When the app starts/restarts, AppSignal will create a deploy in the deploys section for your app.

That's it! You've successfully configured your application to notify AppSignal of deploys! Your application's data will be tracked alongside the appropriate deployment, helping level up your ability to analyze your application's performance.

Are deploys not being reported or incorrectly? Contact us and we will help you out!