Language Runtime Metrics
Last updated 12 September 2017
JVM and Go language runtime metrics are available for all Professional dynos (Standard-1X and above) and Private Spaces. Support for additional languages is planned. For all metrics the resolution is dependent on the timeframe selected. More information on metrics retention and resolution is available in the Application Metrics docs.
JVM Runtime Metrics (Public Beta)
The language runtime metrics feature allows you to view heap and non-heap memory, as well as garbage collection activity, from Java’s JVM.
To get started, first add the
heroku-buildpack-metrics buildpack to your app.
Adding the buildpack via the CLI
To add the buildpack using the command line interface (CLI):
$ heroku buildpacks:add -i 1 heroku/metrics
Next redeploy your application:
$ git commit --allow-empty -m "Add Heroku Metrics Buildpack" $ git push heroku master
Adding the buildpack via the Dashboard
To add the buildpack using the Dashboard:
From the Settings tab for your app add the buildpack using:
Redeploy your app from the Deploy tab or CLI.
Displaying the JVM metrics plots in Application Metrics
Display of JVM metrics plots can be enabled and disabled using the Metrics Beta Features panel. Individual plots may also be hidden.
Heap and non-heap memory
Language runtime metrics will add new heap and non-heap memory graphs to the Metrics tab on Heroku dashboard. Summary metrics for the selected time interval, including latest, average and maximum memory, are also displayed. Heap memory is where dynamically allocated memory resides. If you see heap memory growing unexpectedly, that’s typically an indication of a memory leak. You can use tools like Heroku Exec for further diagnosis.
Garbage collection activity
In addition to new memory graphs, language runtime metrics will add a garbage collection activity chart. The chart displays the amount of time that was spent doing garbage collection for each time increment. High garbage collection activity typically has a negative impact on response time. It may also suggest that your app needs more memory.
Language runtime metrics collects data from the JVM running on your dyno. The overall impact of JVM metrics collection on application performance is minimal. In our testing we observed the following:
- an estimated 1MB of additional peak heap usage
- ~300 additional classes loaded, resulting in < 1MB of additional Metaspace (off-heap) memory
- 9 additional threads (3 running, 5 parked, 1 waiting)
For deployment with the Heroku Maven plugin, you must set the following plugin configuration in your
<configuration> <buildpacks> <buildpack>heroku/metrics</buildpack> <buildpack>jvm-common</buildpack> </buildpacks> <configuration>
For sbt-heroku, add the following code to your
herokuBuildpacks in Compile := Seq( "heroku/metrics", "jvm-common" )
Using with JRuby
To use this feature with JRuby, you must include the
heroku/jvm buildpack with your app by running:
$ heroku buildpacks:add -i 1 heroku/jvm
Then redeploy your application.
The language metrics feature is not compatible with WAR file deployment from the CLI.
Disabling metrics collection
To disable JVM metrics collection remove the buildpack and redeploy your app:
$ heroku buildpacks:remove heroku/metrics $ git commit --allow-empty -m "Remove Heroku Metrics Buildpack" $ git push heroku master
Go Runtime Metrics (Private Beta)
Go Runtime Metrics are currently in private beta. If you have questions or feedback please contact us at email@example.com.
Heroku provides a metrics package named
hmetrics that when imported runs an
init function which periodically reports metrics to the Heroku metrics service. The library makes use of an environment variable that is set at runtime via the
runtime-heroku-metrics feature flag.
The runtime environment variable enabled by the
runtime-heroku-metrics flag is only available inside a running dyno and does not appear in the application’s configuration.
The same feature flag also enables the Go Language metrics UI in the dashboard. To enable the feature flag run the following:
$ heroku labs:enable runtime-heroku-metrics -a <app name>
if you would like to inspect the library further, or require it locally, you can fetch the current version of the library via:
$ go get -u github.com/heroku/x/hmetrics
In each main package you want to instrument, import the
package main import ( _ "github.com/heroku/x/hmetrics/onload" )
Additional examples and alternative ways to initialize the
hmetrics library is available in it’s examples.
hmetrics using one of the supported vendoring tools, commit, and push your app to Heroku.
Stack and Heap Memory Usage
This memory-focused plot displays max stack, max heap, and max GC goal memory usage (in MB), along with the memory quota. In this example to better view the relative usage of GC goal, heap, and stack the memory quota has been toggled off by clicking on the legend entry.
Stop the World GC Time
This plot tracks the stop-the-world time (in ms) when app execution is halted to run garbage collection.
GC Aggregate Collections
The number of GC collection, aggregated across all dynos, is displayed on this plot.
The Heap Objects plot displays the max and average number of heap objects.
Number of Goroutines
The average and max number of Goroutines is displayed in this plot.