Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

prometheus-metrics-core makes io.prometheus.metrics.tracer.initializer a mandatory OSGi import although the code supports its absence

已關閉 適合新手
#2,516 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

已經有一個關聯 PR 被合併了。

  • #2528 來自 @kalayciburak —— 已合併

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
build-system

研究方向

從 prometheus-metrics-core 的 maven-bundle-plugin 說明開始,檢查產生的 OSGi manifest 中是否有 io.prometheus.metrics.tracer.initializer 的匯入。將該匯入設為選用,然後執行 OSGi 測試或 micrometer-osgi-test-tests,並驗證 bundle 在沒有 prometheus-metrics-tracer-initializer 的情況下也能解析。

由索引模型根據 Issue 內容生成。

描述

prometheus-metrics-core 1.9.0 ships Import-Package: io.prometheus.metrics.tracer.initializer;version="[1.9,2)" with no resolution:=optional, so an OSGi deployment that leaves out prometheus-metrics-tracer-initializer cannot resolve the bundle.

The code is written for that artifact to be absent. ExemplarSampler.sampleTraceContextLabels() calls SpanContextSupplier through its fully qualified name on purpose, and the comment says why:

// Using the qualified name so that Micrometer can exclude the dependency on
// prometheus-metrics-tracer-initializer
// as they provide their own implementation of SpanContextSupplier.
// If we had an import statement for SpanContextSupplier the dependency would be needed in any case.

The block that follows is guarded with catch (NoClassDefFoundError ignored).

Micrometer does exactly what that comment describes: micrometer-registry-prometheus excludes the artifact from prometheus-metrics-core. On the Maven side it works. In OSGi it does not resolve:

⇒ Bundle: micrometer-osgi-test-tests cannot be resolved
    ⇒ because Import-Package requirement for: io.micrometer.prometheusmetrics could not be provided
        ⇒ because Import-Package requirement for: io.prometheus.metrics.core.exemplars; version=[1.9.0,2.0.0)
            ⇒ because Import-Package requirement for: io.prometheus.metrics.tracer.initializer; version=[1.9.0,2.0.0)

Dropping prometheus-metrics-tracer-initializer onto the runtime makes it resolve and the tests pass, so that import is the only thing missing.

Marking it optional in the maven-bundle-plugin instructions for prometheus-metrics-core would line the manifest up with what the code already allows, the same way _exportcontents was added to prometheus-metrics-exposition-formats for #2395.

主要語言
Java
星號
2.3k
分支
832
平均合併
1 天 9 小時
30 天內合併 PR
73

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

prometheus/client_java 的其他 Issue

查看 prometheus/client_java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。