Go Language Runtime Metrics (Public Beta)
Last updated 15 November 2017
To provide more visibility into the Go runtime, the Go runtime metrics feature surfaces additional language-specific time series metrics within Application Metrics. Go metrics include:
- Heap and stack memory usage
- Stop the world garbage collection (GC) time
- GC aggregate collections
- Heap object count
- Number of Goroutines
The feature is currently in self-serve public beta. If you have questions or feedback, you can reach us at firstname.lastname@example.org.
Go language metrics are available for all paid dynos (Hobby and above) and Private Spaces.
For general information on metrics display settings, please refer to the language runtime metrics parent document.
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.
Heap and Stack 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.