From e058c20ecb14ee0aa859824053bc6895f99c5ea6 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 4 Aug 2020 13:49:09 -0400 Subject: [PATCH] Rename Go version tag from `version` to `go_version` (#122) Most of our services will set a version tag that represents the version of their service. However, the Go stats reported by the `procstats` package will overwrite this tag with the current Go runtime version. This becomes a bigger issue when scraping these stats via Prometheus, since it will consider a sample as invalid if labels are not unique: ![image](https://user-images.githubusercontent.com/2907397/89065716-3345d580-d33a-11ea-93e7-ab4833388980.png) This PR makes a breaking change to resolve this issue, by renaming the tag that specifics the Go runtime version from `version` to `go_version`. --- README.md | 4 ++++ procstats/go.go | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4c530b2..7ebe2a7 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,10 @@ Monitoring ### Processes +> 🚧 Go metrics reported with the `procstats` package were previously tagged with a +> `version` label that reported the Go runtime version. This label was renamed to +> `go_version` in v4.6.0. + The [github.com/segmentio/stats/procstats](https://godoc.org/github.com/segmentio/stats/procstats) package exposes an API for creating a statistics collector on local processes. diff --git a/procstats/go.go b/procstats/go.go index 6be8356..c2eacec 100644 --- a/procstats/go.go +++ b/procstats/go.go @@ -23,8 +23,8 @@ func init() { // GoMetrics is a metric collector that reports metrics from the Go runtime. type GoMetrics struct { - engine *stats.Engine - version string `tag:"version"` + engine *stats.Engine + goVersion string `tag:"go_version"` runtime struct { // Runtime info. @@ -113,8 +113,8 @@ func NewGoMetrics() *GoMetrics { // metrics on eng. func NewGoMetricsWith(eng *stats.Engine) *GoMetrics { g := &GoMetrics{ - engine: eng, - version: runtime.Version(), + engine: eng, + goVersion: runtime.Version(), } g.memstats.total.memtype = "total"