Go Language Metrics (Public Beta)
Last updated 10 January 2018
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.
First, enable the Enhanced Language Metrics feature (by following these instructions).
Next, you must opt into the public beta for Go Language metrics. You can either do this in Dashboard through the labs panel at the top of the metrics page, or by running this command in the CLI:
heroku labs:enable "go-language-metrics" -a "my-app-name"
The beta flag may not appear in the labs panel if you are not using the Go buildpack. In this case, you will need to opt in via the CLI command above.
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.
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 the example section on the Github repo.
hmetrics using one of the supported vendoring tools, commit, and push your app to Heroku.
It may take a few minutes for these metrics to become available after the steps above are completed.
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 total stop-the-world time (when app execution is halted) to run garbage collection across all dynos of the current process type.
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.
Disabling Metrics Collection
To disable Go metrics collection, simply toggle off the Enhanced Language Metrics toggle via the Metrics Preferences panel, or by using this CLI command:
$ heroku labs:disable "runtime-heroku-metrics" -a "my-app-name"