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

未关闭 适合新手
#9,014 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@rooks-ns 已经在做这个了。

开始于 2026年11月7日。

  • #9015 来自 @rooks-ns —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java, prometheus

调研方向

从 exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/internal/PrometheusComponentProvider.java 开始,重点查看第 63–76 行附近对 resource_constant_labels 的解析,并追踪空配置如何传递到 IncludeExcludePredicate.createPatternMatching。先检查相关的 predicate 测试和 Prometheus exporter 测试。完成标准是空 map 不会将 resource 属性添加为 metric 标签,并且该配置有回归测试覆盖。

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Java
星标
2.5k
派生
1k
平均合并
4 天 3 小时
30 天内合并 PR
52

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-telemetry/opentelemetry-java 的其他 Issue

查看 open-telemetry/opentelemetry-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。