Skip to content

Commit

Permalink
Rename Go version tag from version to go_version (#122)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
colinking committed Aug 4, 2020
1 parent 02d3072 commit e058c20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions procstats/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit e058c20

Please sign in to comment.