VictoriaMetrics / metrics

Lightweight alternative to github.com/prometheus/client_golang
MIT License
543 stars 63 forks source link

Tag 1.25.0+ is not compatible with go 1.20 #59

Closed ryanrazsa closed 11 months ago

ryanrazsa commented 11 months ago

New runtime metrics were added in this PR.

Specifically the metric "/gc/gomemlimit:bytes", "go_memlimit_bytes" is not available in go 1.20. It was added in this commit.

Using go 1.20 causes the following panic:

panic: BUG: unexpected runtimemetrics.KindBad for sample.Name="/gc/gomemlimit:bytes"

goroutine 140 [running]:
github.com/VictoriaMetrics/metrics.writeRuntimeMetric({0xe0f8c0, 0xc0002fe7e0}, {0xd23363?, 0x0?}, 0x0?)
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/go_metrics.go:97 +0x1d7
github.com/VictoriaMetrics/metrics.writeRuntimeMetrics({0xe0f8c0, 0xc0002fe7e0})
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/go_metrics.go:90 +0x139
github.com/VictoriaMetrics/metrics.writeGoMetrics({0xe0f8c0, 0xc0002fe7e0})
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/go_metrics.go:26 +0x46
github.com/VictoriaMetrics/metrics.WriteProcessMetrics({0xe0f8c0, 0xc0002fe7e0})
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/metrics.go:213 +0x25
github.com/VictoriaMetrics/metrics.WritePrometheus({0xe0f8c0, 0xc0002fe7e0}, 0x1)
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/metrics.go:88 +0x299
github.com/VictoriaMetrics/metrics.InitPush.func1({0xe0f8c0?, 0xc0002fe7e0?})
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/push.go:53 +0x27
github.com/VictoriaMetrics/metrics.InitPushExt.func1()
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/push.go:128 +0x1b4
created by github.com/VictoriaMetrics/metrics.InitPushExt
    /home/runner/go/pkg/mod/github.com/!victoria!metrics/metrics@v1.25.3/push.go:121 +0x68e

Steps to reproduce:

Using go 1.20

func TestMetrics(t *testing.T) {
    var bb bytes.Buffer
    writeRuntimeMetrics(&bb)
    fmt.Println(bb.String())
}

This same test passes using go 1.21

jombG commented 11 months ago

Hi! I can say that this version also doesn't work with go v1.18

jombG commented 11 months ago

I think that we can skip these metrics for previous versions of golang

I will prepare PR for this issue

jombG commented 11 months ago

I think that we have the simplest solution for this case I propose to remove panic in this case

https://github.com/VictoriaMetrics/metrics/pull/60

valyala commented 11 months ago

@ryanrazsa , thanks for the bugreport! @jombG , thanks for the initial attempt to fix the issue at https://github.com/VictoriaMetrics/metrics/pull/60 !

The issue has been fixed in the commit 447d235cbb84d47adde5cd96943eb0d0d44a8836 . This commit logs unsupported Go runtime metrics at startup, so the user could remove these log lines by upgrading Go builder. The commit also lowers the minimum supported Go version from Go1.20 to Go1.16. This commit has been included in the tag v1.25.4. Closing the issue as fixed then.