expfmt: OpenMetrics 1.0 output with a unit that is not a name suffix fails the whole scrape in Prometheus

Đang mở
#1,005 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@itsmeasadali đang làm issue này rồi.

Từ ngày 10/10/2026.

  • #1012 của @itsmeasadali — đang mở
  • #1018 của @AdamMagued — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
observability-sre

Hướng nghiên cứu

Start at MetricFamilyToOpenMetrics and inspect the OpenMetrics 1.0 parsing behavior described in the reproduction. Review test case 16 and determine which proposed behavior is preferred; done when the non-suffix unit case no longer causes Prometheus to reject the exposition and the test reflects the decision.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Since #877, MetricFamilyToOpenMetrics no longer adds the unit to the metric name, but it still writes the # UNIT line. OpenMetrics 1.0 requires the unit to be a suffix of the name, and Prometheus's OpenMetrics 1.0 parser rejects the exposition, so every metric on the target is lost (the same failure as prometheus/client_golang#1990).

Reproduction with client_golang v1.24.1:

reg := prometheus.NewRegistry()
reg.MustRegister(prometheus.NewCounter(prometheus.CounterOpts{
	Name: "request_duration_total", Help: "Time spent.", Unit: "seconds",
}))
// promhttp.HandlerFor(reg, promhttp.HandlerOpts{EnableOpenMetrics: true})
# HELP request_duration Time spent.
# TYPE request_duration counter
# UNIT request_duration seconds
request_duration_total 1.5
# EOF

Prometheus: unit "seconds" not a suffix of metric "request_duration".

Options I can see:

  1. The OpenMetrics 1.0 encoder omits # UNIT when the unit is not a suffix, the same way it already writes a counter without _total as unknown "to avoid invalid OpenMetrics output". Names are never changed. (Test case 16 would change.)
  2. Prometheus's OpenMetrics 1.0 parser stops rejecting it, following OpenMetrics 2.0, where the suffix is only a SHOULD.

Happy to send a PR for whichever is preferred.

Ngôn ngữ chính
Go
Star
297
Fork
380
Merge trung bình
3 ngày 15 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của prometheus/common

Tất cả issue của prometheus/common

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.