prometheus / prometheus/client_python

TypeError in floatToGoString in utils.py

Đang mở
#907 1 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ả

When one PureStorage array controller is failed it reports None value for metric purefa_network_interface_performance. The function floatToGoString fails because it cannot handle None value.

I added two lines in my local copy of "utils.py" to make this function work, so it replaces None value with 0 (zero).

Instead of:

def floatToGoString(d):
   d = float(d)

I use:

def floatToGoString(d):
    if d is None:
        d = 0
    d = float(d)

Below is the error message:

File "/home/pure_exporter/venv/lib/python3.7/site-packages/prometheus_client/utils.py", line 9, in floatToGoString
d = float(d)
TypeError: ("float() argument must be a string or a number, not 'NoneType'", Metric(purefa_network_interface_performance, FlashArray network interface performance, gauge, , [Sample(name='purefa_network_interface_performance', labels={'interface': 'ct0.eth5', 'dimension': 'rx_bytes'}, value=None, timestamp=None, exemplar=None),

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 trong utils.py tại floatToGoString và tái hiện lỗi với giá trị None. Xem lại các kiểm thử hiện có xung quanh tiện ích này, sau đó thêm kiểm thử hồi quy cho thấy None được xử lý như bằng không trong khi các đầu vào số thông thường vẫn hoạt động. Hoàn tất khi metric được báo cáo có thể được tuần tự hóa mà không gặp TypeError.

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

Đánh giá

Công nghệ
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
Đặc tả 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.