Heroku add-on

Codekvast is an add-on for detecting Truly Dead Code in your app.

By "Truly Dead Code", we mean code in your production app that has not executed for a significant period of time.

Continuously detecting and removing dead code from your app provides the following benefits:

  • Shorter development cycles
  • Reduced technical debt
  • Reduced risk for security exploits
  • Faster developer onboarding

Codekvast requires minimal changes to your application. It is currently available for Java and other JVM languages such as Scala.
It requires a JDK with at least version 8. It is tested on versions 8 to 15.

Install the Codekvast add-on

Codekvast can be attached to a Heroku application via the CLI:

A list of all available plans can be found here.

$ heroku addons:create codekvast
-----> Adding codekvast to sharp-mountain-4005... done, v18 (free)

Installing the add-on automatically creates a private Codekvast account connected to your Heroku account. You can access your Codekvast account from your app's Add-ons list in the Heroku Dashboard.

After you provision Codekvast, the CODEKVAST_URL and CODEKVAST_LICENSE_KEY config vars are available in your app's configuration. They contain information for accessing the newly provisioned Codekvast service instance. You can confirm this via the heroku config:get command:

$ heroku config:get CODEKVAST_URL
https://api.codekvast.io/

After you attach Codekvast to your app, you'll need to configure it.

Configure your Codekvast javaagent

Manual configuration

  1. Download codekvast-agent-1.4.1.zip and unzip it into your project's root directory. The ZIP file includes a sample codekvast.conf file, as well as a codekvast/ directory that contains the Java agent.

  2. Edit codekvast.conf to suit your app's needs. Do not change the serverUrl or licenseKey values, because they are injected from your Heroku environment.

    Full documentation of all configuration parameters file is available at
    https://www.codekvast.io/pages/getting-started.html.

  3. Update your app's JAVA_OPTS config var to include the javaagent:

    heroku config:set JAVA_OPTS="-javaagent:/app/codekvast/codekvast-javaagent-1.4.1.jar"
    

Using Codekvast with Gradle

Using spring-boot-gradle-plugin to build an executable JAR file is supported.

See Codekvast Getting Started to learn how to use Codekvast with spring-boot-gradle-plugin.

The standard standard Gradle application plugin is also supported.

A sample application that illustrates how to use codekvast-agent with the
Gradle application plugin is available on Github.

The sample application also illustrates how to download codekvast-javaagent via Gradle's dependency mechanism.

Using Codekvast with Maven

Using spring-boot-maven-plugin to build an executable JAR file is supported.

See Codekvast Getting Started to learn how to use Codekvast with spring-boot-maven-plugin.

Testing locally

After you install the add-on and configure the Codekvast java agent, you can test locally that everything works as expected, and that data collection is taking place.

It's necessary to locally replicate the add-on's config vars so your development environment can operate against the service.

Use the Heroku Local command-line tool to configure, run and manage process types specified in your app's Procfile. Heroku Local reads configuration variables from a .env file. To view all of your app's config vars, type heroku config. Use the following command for each value that you want to add to your .env file:

heroku config:get CODEKVAST_URL -s  >> .env
heroku config:get CODEKVAST_LICENSE_KEY -s  >> .env
heroku config:get JAVA_OPTS -s  >> .env

Warning
Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

For more information, see the Heroku Local article.

Monitoring and logging

You can monitor Codekvast activity within the Heroku log-stream by running the following command:

$ heroku logs -t | grep -i codekvast

You should see the string Codekvast uploaded within a few minutes after the application starts if the integration is working correctly.

After the initial upload, Codekvast will upload data according to your selected plan.

Dashboard

note
For more information on features available in the Codekvast dashboard, please see the documentation at www.codekvast.io.

The Codekvast dashboard allows you to browse your collected usage data.

You can access the dashboard via the CLI:

$ heroku addons:open codekvast
Opening codekvast for sharp-mountain-4005

or by visiting the Heroku Dashboard and selecting the application in question. Select Codekvast from the Add-ons menu.

Migrating between plans

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade codekvast:newplan
-----> Upgrading codekvast:newplan to sharp-mountain-4005... done, v18 ($49/mo)
       Your plan has been updated to: codekvast:newplan

Uninstalling the Codekvast add-on

Use the following procedure for uninstalling the Codekvast add-on:

  1. Remove codekvast.conf from your project root.
  2. Remove codekvast/codekvast-javaagent-1.4.1.jar
  3. Revert the changes to your build system, or run heroku config:unset JAVA_OPTS
  4. git push heroku master

Then deprovision the Codekvast service via the CLI:

Warning
This will destroy all collected data and cannot be undone!

$ heroku addons:destroy codekvast
-----> Removing codekvast from sharp-mountain-4005... done, v20 (free)

Support

All Codekvast support and runtime issues should be submitted via one of the Heroku Support channels.

Any non-support related issues or product feedback is welcome at https://github.com/crispab/codekvast/issues.

There is also a Slack team for Codekvast. Send an email to support@codekvast.io for an invitation.


Updated 16 April 2021