PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})

Đang mở Phù hợp với người mới
#9,014 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

@rooks-ns đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #9015 của @rooks-ns — đang mở

Đánh giá

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

Hướng nghiên cứu

Bắt đầu trong exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/internal/PrometheusComponentProvider.java, đặc biệt là phần phân tích resource_constant_labels quanh các dòng 63–76, và lần theo cách một cấu hình trống đi đến IncludeExcludePredicate.createPatternMatching. Trước tiên, kiểm tra các bài kiểm thử predicate liên quan và các bài kiểm thử của Prometheus exporter. Công việc hoàn tất khi một map trống không thêm thuộc tính resource làm nhãn metric và có kiểm thử hồi quy cho cấu hình đó.

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

Mô tả

Describe the bug

In PrometheusComponentProvider.java, configuring an empty resource_constant_labels: {} map in declarative configuration promotes all resource attributes onto every Prometheus metric series instead of none.

resource_constant_labels: {} is currently valid against the opentelemetry-configuration JSON Schema ($defs.IncludeExclude sets minItems: 1 on included and excluded, not minProperties: 1 on the object). When parsed:

meter_provider:
  readers:
    - pull:
        exporter:
          prometheus/development:
            resource_constant_labels: {}

config.getStructured("resource_constant_labels") returns a non-null DeclarativeConfigProperties where both included and excluded are null, and passes (null, null) to IncludeExcludePredicate.createPatternMatching(null, null), which returns an include-all predicate (attributeKey -> true).

Expected behavior

Per the Prometheus exporter specification (By default, it MUST NOT add any resource attributes as metric labels) and ExperimentalPrometheusMetricExporter.resource_constant_labels (defaultBehavior: no resource attributes are added), when both included and excluded are null (matching Collector's pkg/resourcetotelemetry IsEmpty() check), no resource attributes should be added as metric labels (or empty {} should be rejected if disallowed by opentelemetry-configuration).

Ngôn ngữ chính
Java
Star
2.5k
Fork
1k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
52

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 open-telemetry/opentelemetry-java

Tất cả issue của open-telemetry/opentelemetry-java

Issue tương tự

Thêm issue về Java

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.