prometheus / prometheus/client_python

Non-stringy label values in MetricFamily metrics cause export-time errors

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

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
4.4k
Fork
876
Merge trung bình
8 ngày 4 giờ
Pull request đã merge (30 ngày)
1

Mô tả

This is very similar to #18 only I'm using the GaugeMetricFamily/CounterMetricFamily interface, otherwise the symptoms are the same. I'm using the default pypi version (which I think is 0.2.0).

I was inadvertently passing in ints for a couple of the label values in .add_metric(), which results in a 500 error on export and the following traceback. Wrapping a str() around the values makes this go away. Coercing these values as was done in the fix for #18 seems like the right thing to do here as well.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/socketserver.py", line 639, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python3.6/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "/usr/local/lib/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "/usr/local/lib/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 95, in do_GET
    output = generate_latest(registry)
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 78, in generate_latest
    for k, v in sorted(labels.items())]))
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 78, in <listcomp>
    for k, v in sorted(labels.items())]))
AttributeError: 'int' object has no attribute 'replace'

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

Hướng nghiên cứu

Bắt đầu với GaugeMetricFamily và CounterMetricFamily, lần theo .add_metric() qua generate_latest trong exposition.py đến nơi traceback xảy ra. Xác minh rằng các giá trị label dạng số nguyên được chấp nhận trong quá trình export mà không gây ra lỗi replace(), đồng thời giữ nguyên hành vi hiện có được mô tả cho issue #18.

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

Đánh giá

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

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.