Heroku Labs: Dyno Metadata
Last updated May 13, 2024
Dyno metadata gives the dyno easy access to information about the app and environment. Examples of available dyno metadata include details about the release, dyno size, application name as well as the unique identifier for the particular running dyno.
Dyno metadata can be used to:
Get release information: Knowing which git SHA of the release your dyno is running is useful for continuous integration, callbacks, and debugging.
Easily access the application name: Knowing your application name can make debugging easier when you are running multiple versions of the same application across regions.
Features added through Heroku Labs are experimental and subject to change.
Usage
Dyno processes are able to inspect metadata as config vars set in the dyno. For an app to get these variables, you must first enable the labs feature on the application.
You can enable this feature by running:
$ heroku labs:enable runtime-dyno-metadata -a <app name>
For additional config vars, enable this flag. See the following table for the config vars available with this flag.
$ heroku labs:enable runtime-dyno-build-metadata -a <app name>
The metadata is available the next time you deploy the app.
Dyno Metadata
The following dyno metadata are available:
Name | Description | Example |
---|---|---|
HEROKU_APP_ID | The unique identifier for the application. | "9daa2797-e49b-4624-932f-ec3f9688e3da" |
HEROKU_APP_NAME | The application name. | "example-app" |
HEROKU_APP_DEFAULT_DOMAIN_NAME | The default DNS hostname for the app. | "example-app-1234567890ab.herokuapp.com" |
HEROKU_DYNO_ID | The dyno identifier. This metadata is not yet available in Private Spaces nor the Container Registry. | "1vac4117-c29f-4312-521e-ba4d8638c1ac" |
HEROKU_RELEASE_CREATED_AT | The time and date the release was created. | "2015-04-02T18:00:42Z" |
HEROKU_RELEASE_VERSION | The identifier for the current release. | "v42" |
HEROKU_SLUG_COMMIT | The commit hash for the current release. This field is deprecated. Use HEROKU_BUILD_COMMIT instead. | "2c3a0b24069af49b3de35b8e8c26765c1dba9ff0" |
HEROKU_SLUG_DESCRIPTION | The description of the current release. This field is deprecated. Use HEROKU_BUILD_DESCRIPTION instead. | "Deploy 2c3a0b2" |
HEROKU_BUILD_COMMIT | The commit hash for the current build.* | "2c3a0b24069af49b3de35b8e8c26765c1dba9ff0" |
HEROKU_BUILD_DESCRIPTION | The description of the current build.* | "Deploy 2c3a0b2" |
Config vars with an asterisk (*) in the description are available with the runtime-dyno-build-metadata
flag.
In certain situations, such as pushing a tarball manually using the Releases API, the slug commit hash may be null.
It is not recommended that you set HEROKU_* environment variables on your application as it runs the risk of conflicting with these changes.
Example Dyno Metadata
$ env
HEROKU_APP_ID: 9daa2797-e49b-4624-932f-ec3f9688e3da
HEROKU_APP_NAME: example-app
HEROKU_APP_DEFAULT_DOMAIN_NAME: example-app-1234567890ab.herokuapp.com
HEROKU_DYNO_ID: 1vac4117-c29f-4312-521e-ba4d8638c1ac
HEROKU_RELEASE_CREATED_AT: 2015-04-02T18:00:42Z
HEROKU_RELEASE_VERSION: v42
HEROKU_SLUG_COMMIT: 2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
HEROKU_SLUG_DESCRIPTION: Deploy 2c3a0b2
HEROKU_BUILD_COMMIT: 2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
HEROKU_BUILD_DESCRIPTION: Deploy 2c3a0b2
...
Removal
If you no longer wish to participate in this lab, please remove the lab from your app and then remove any config vars you may not want. Out of concern for removing config vars that your application may be depending upon, removal of the lab will not remove config vars at this time. As with all labs, this functionality is experimental and may change.
You can disable the continued updating of the config vars by opting out of the lab:
$ heroku labs:disable runtime-dyno-metadata -a <app name>
$ heroku labs:disable runtime-dyno-build-metadata -a <app name>
You can remove the config vars by unsetting any you wish to remove. Here we remove all config vars set by this feature:
$ heroku config:unset HEROKU_APP_ID HEROKU_APP_NAME HEROKU_DYNO_ID \
HEROKU_APP_DEFAULT_DOMAIN_NAME HEROKU_RELEASE_CREATED_AT HEROKU_RELEASE_VERSION \
HEROKU_SLUG_COMMIT HEROKU_SLUG_DESCRIPTION \
HEROKU_BUILD_COMMIT HEROKU_BUILD_DESCRIPTION -a <app name>