Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the runtime/metrics package for the Go collector for 1.17+ #955

Merged
merged 1 commit into from Jan 16, 2022

Commits on Jan 11, 2022

  1. Use the runtime/metrics package for the Go collector for 1.17+

    This change introduces use of the runtime/metrics package in place of
    runtime.MemStats for Go 1.17 or later. The runtime/metrics package was
    introduced in Go 1.16, but not all the old metrics were accounted for
    until 1.17.
    
    The runtime/metrics package offers several advantages over using
    runtime.MemStats:
    * The list of metrics and their descriptions are machine-readable,
      allowing new metrics to get added without any additional work.
    * Detailed histogram-based metrics are now available, offering much
      deeper insights into the Go runtime.
    * The runtime/metrics API is significantly more efficient than
      runtime.MemStats, even with the additional metrics added, because
      it does not require any stop-the-world events.
    
    That being said, integrating the package comes with some caveats, some
    of which were discussed in prometheus#842. Namely:
    * The old MemStats-based metrics need to continue working, so they're
      exported under their old names backed by equivalent runtime/metrics
      metrics.
    * Earlier versions of Go need to continue working, so the old code
      remains, but behind a build tag.
    
    Finally, a few notes about the implementation:
    * This change includes a whole bunch of refactoring to avoid significant
      code duplication.
    * This change adds a new histogram metric type specifically optimized
      for runtime/metrics histograms. This type's methods also include
      additional logic to deal with differences in bounds conventions.
    * This change makes a whole bunch of decisions about how runtime/metrics
      names are translated.
    * This change adds a `go generate` script to generate a list of expected
      runtime/metrics names for a given Go version for auditing. Users of
      new versions of Go will transparently be allowed to use new metrics,
      however.
    
    Signed-off-by: Michael Anthony Knyszek <mknyszek@google.com>
    mknyszek committed Jan 11, 2022
    Copy the full SHA
    48b3521 View commit details
    Browse the repository at this point in the history