-
Notifications
You must be signed in to change notification settings - Fork 588
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
host / runtime metrics broken in prometheus #2787
Milestone
Comments
To reproduce: package main
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/contrib/instrumentation/host"
otelprom "go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
)
func main() {
exporter := otelprom.New()
provider := metric.NewMeterProvider(metric.WithReader(exporter))
registry := prometheus.NewRegistry()
if err := registry.Register(exporter.Collector); err != nil {
panic(err)
}
// this generates metrics that are rejected by the prometheus module
if err := host.Start(host.WithMeterProvider(provider)); err != nil {
panic(err)
}
// similar for `runtime` instrumentation
// this metric does work
counter, err := provider.Meter("my_meter").SyncInt64().Counter("my_counter")
if err != nil {
panic(err)
}
counter.Add(context.Background(), 1)
handler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
w := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/", nil)
handler.ServeHTTP(w, r)
fmt.Println("body:\n", w.Body.String())
} Output: $ go run main.go
2022/09/21 11:56:30 "system.network.io" is not a valid metric name
2022/09/21 11:56:30 "system.network.io" is not a valid metric name
2022/09/21 11:56:30 "process.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "process.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "system.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "system.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "system.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "system.cpu.time" is not a valid metric name
2022/09/21 11:56:30 "system.memory.usage" is not a valid metric name
2022/09/21 11:56:30 "system.memory.usage" is not a valid metric name
2022/09/21 11:56:30 "system.memory.utilization" is not a valid metric name
2022/09/21 11:56:30 "system.memory.utilization" is not a valid metric name
body:
# HELP my_counter
# TYPE my_counter counter
my_counter 1 |
Thanks for the bug report. This is currently identified and tracked by open-telemetry/opentelemetry-go#3183. Closing this as it is a duplicate. Please follow the other issue to track the resolution. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the new Metrics API (v0.32.0), we somewhere ends up calling https://github.com/prometheus/common/blob/main/model/metric.go#L92 which rejects any metrics with dots such as the ones created by by the
host
andruntime
instrumentation (e.g.process.cpu.time
).As a result, every time when Prometheus collects the metrics my logs are being spammed full with "xxx is not a valid metric name" errors (directly to stderr, which is another issue) and those metrics aren't returned to Prometheus.
Note: prior to the new Metrics API this worked (v0.31.0).
An example to reproduce this can be found in the comment below.
The text was updated successfully, but these errors were encountered: